goutil icon indicating copy to clipboard operation
goutil copied to clipboard

Dump: Can dump provide a parameter to control nil/zero not to print?

Open lx-world opened this issue 4 years ago • 1 comments

Example:

type T1 struct {
	T2 *T2
	T3 *T3
}

type T2 struct {
	Name2 string
}

type T3 struct {
	Name3 string
}

func main() {
	t1 := &T1{
		T2: &T2{
			Name2: "xx",
		},
	}
	dump.P(t1)
}

output:

PRINT AT main.main(main.go:27)
&main.T1 {
  T2: &main.T2 {
    Name2: string("xx"), #len=2
  },
  T3: *main.T3<nil>,
}

i want to ignore T3: *main.T3<nil>

lx-world avatar Mar 30 '22 08:03 lx-world

hi @lx-world

Why do you need this setting?

inhere avatar Apr 08 '22 02:04 inhere

add new option: SkipNilField, will release at next version.

inhere avatar Dec 12 '22 05:12 inhere