Skip to content

Commit

Permalink
Merge pull request shirou#659 from mingrammer/gofmt
Browse files Browse the repository at this point in the history
Refactor with gofmt
  • Loading branch information
shirou authored Mar 23, 2019
2 parents 68c6fbd + 64a995a commit 2cbc919
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions mem/mem_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
)

type VirtualMemoryExStat struct {
ActiveFile uint64 `json:"activefile"`
InactiveFile uint64 `json:"inactivefile"`
ActiveFile uint64 `json:"activefile"`
InactiveFile uint64 `json:"inactivefile"`
}

func VirtualMemory() (*VirtualMemoryStat, error) {
Expand All @@ -28,9 +28,9 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {

// flag if MemAvailable is in /proc/meminfo (kernel 3.14+)
memavail := false
activeFile := false // "Active(file)" not available: 2.6.28 / Dec 2008
inactiveFile := false // "Inactive(file)" not available: 2.6.28 / Dec 2008
sReclaimable := false // "SReclaimable:" not available: 2.6.19 / Nov 2006
activeFile := false // "Active(file)" not available: 2.6.28 / Dec 2008
inactiveFile := false // "Inactive(file)" not available: 2.6.28 / Dec 2008
sReclaimable := false // "SReclaimable:" not available: 2.6.19 / Nov 2006

ret := &VirtualMemoryStat{}
retEx := &VirtualMemoryExStat{}
Expand Down Expand Up @@ -123,7 +123,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
ret.Cached += ret.SReclaimable

if !memavail {
if (activeFile && inactiveFile && sReclaimable) {
if activeFile && inactiveFile && sReclaimable {
ret.Available = calcuateAvailVmem(ret, retEx)
} else {
ret.Available = ret.Cached + ret.Free
Expand Down Expand Up @@ -192,7 +192,7 @@ func calcuateAvailVmem(ret *VirtualMemoryStat, retEx *VirtualMemoryExStat) uint6
lines, err := common.ReadLines(fn)

if err != nil {
return ret.Free + ret.Cached // fallback under kernel 2.6.13
return ret.Free + ret.Cached // fallback under kernel 2.6.13
}

pagesize := uint64(os.Getpagesize())
Expand Down
6 changes: 3 additions & 3 deletions process/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ func Test_Process_memory_maps(t *testing.T) {
if len(*mmaps) != 1 {
t.Errorf("grouped memory maps length (%v) is not equal to 1", len(*mmaps))
}
if (*mmaps)[0] == empty {
t.Errorf("memory map is empty")
}
if (*mmaps)[0] == empty {
t.Errorf("memory map is empty")
}
}
func Test_Process_MemoryInfo(t *testing.T) {
p := testGetProcess()
Expand Down

0 comments on commit 2cbc919

Please sign in to comment.