package dumpimport ()// Options for dumpertypeOptionsstruct {// Output the output writer Output io.Writer// NoType don't show data type TODO NoType bool// NoColor don't with color NoColor bool// IndentLen width. default is 2 IndentLen int// IndentChar default is one space IndentChar byte// MaxDepth for nested print MaxDepth int// ShowFlag for display caller position ShowFlag int// CallerSkip skip for call runtime.Caller() CallerSkip int// ColorTheme for print result. ColorTheme Theme// SkipNilField value dump on map, struct. SkipNilField bool// SkipPrivate field dump on struct. SkipPrivate bool// BytesAsString dump handle. BytesAsString bool// ShowLen display length information for string, slice, array, map ShowLen bool// MoreLenNL array/slice elements length > MoreLenNL, will wrap new line // MoreLenNL int // MaxElementsNum for a long-long slice or array. The excess will be displayed `...` MaxElementsNum int}// OptionFunc typetypeOptionFuncfunc(opts *Options)// NewDefaultOptions create.func ( io.Writer, int) *Options {if == nil { = os.Stdout }return &Options{Output: ,// ---MaxDepth: 5,ShowFlag: Ffunc | Ffname | Fline,// MoreLenNL: 8, // ---IndentLen: 2,IndentChar: ' ',CallerSkip: ,ColorTheme: defaultTheme,// ---ShowLen: true, // show length by default for backward compatibilityMaxElementsNum: 99, }}// SkipNilField setting.func () OptionFunc {returnfunc( *Options) { .SkipNilField = true }}// SkipPrivate field dump on struct.func () OptionFunc {returnfunc( *Options) { .SkipPrivate = true }}// BytesAsString setting.func () OptionFunc {returnfunc( *Options) { .BytesAsString = true }}// WithCallerSkip on print caller position information.func ( int) OptionFunc {returnfunc( *Options) { .CallerSkip = }}// WithoutPosition dont print call dump position information.func () OptionFunc {returnfunc( *Options) { .ShowFlag = Fnopos }}// WithoutOutput setting.func ( io.Writer) OptionFunc {returnfunc( *Options) { .Output = }}// WithoutColor setting.func () OptionFunc {returnfunc( *Options) { .NoColor = true }}// WithoutType setting.func () OptionFunc {returnfunc( *Options) { .NoType = true }}// WithoutLen setting. hide length information for string, slice, array, map.func () OptionFunc {returnfunc( *Options) { .ShowLen = false }}
The pages are generated with Goldsv0.8.4. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.