No pretty-print on FreeBSD VMs
xxxserxxx opened this issue · comments
Sean Russell commented
According to the README, Dump
is supposed to pretty-print structures, with fields separated by newlines. This does not happen under some circumstances.
Environment
- Go version: go version go1.14.1 freebsd/amd64
- OS: FreeBSD freebsd 12.1-RELEASE FreeBSD 12.1-RELEASE r354233 GENERIC amd64
- Host OS: Linux glamdring 5.6.14-arch1-1 #1 SMP PREEMPT Wed, 20 May 2020 20:43:19 +0000 x86_64 GNU/Linux
- VM: QEMU 5.0.0-6
Program
package main
import "github.com/shirou/gopsutil/mem"
import "github.com/davecgh/go-spew/spew"
func main() {
m, e := mem.VirtualMemory()
if e != nil {
panic(e)
}
s, e := mem.SwapMemory()
if e != nil {
panic(e)
}
spew.Dump(m,s)
}
Output
root@freebsd:~/memory # go run main.go
(*mem.VirtualMemoryStat)(0xc000086000)({"total":93827072,"available":39833600,"used":53993472,"usedPercent":57.54572837997118,"free":34660352,"active":4718592,"inactive":4960256,"wired":44883968,"laundry":212992,"buffers":18677760,"cached":0,"writeback":0,"dirty":0,"writebacktmp":0,"shared":0,"slab":0,"sreclaimable":0,"sunreclaim":0,"pagetables":0,"swapcached":0,"commitlimit":0,"committedas":0,"hightotal":0,"highfree":0,"lowtotal":0,"lowfree":0,"swaptotal":0,"swapfree":0,"mapped":0,"vmalloctotal":0,"vmallocused":0,"vmallocchunk":0,"hugepagestotal":0,"hugepagesfree":0,"hugepagesize":0})
(*mem.SwapMemoryStat)(0xc000018190)({"total":1073741824,"used":26644480,"free":1047097344,"usedPercent":2.4814605712890625,"sin":0,"sout":0,"pgin":0,"pgout":0,"pgfault":0})
Expected
More newlines. Or any newlines.
Josh Rickmar commented
This is because the types implement fmt.Stringer, and that is how they are formatting themselves.
Sean Russell commented
Ok, thank you.