Debian Codegraph @

internal/spew/config.go

raw
1 /*
2 * Copyright (c) 2013-2016 Dave Collins <[email protected]>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 package spew
18
19 // ConfigState houses the configuration options used by spew to format and
20 // display values. There is a global instance, Config, that is used to control
21 // top-level Sdump functionality.
22 //
23 // The zero value for ConfigState provides no indentation. You would typically
24 // want to set it to a space or a tab.
25 type ConfigState struct {
26 // Indent specifies the string to use for each indentation level. The
27 // global config instance that all top-level functions use set this to a
28 // single space by default. If you would like more indentation, you might
29 // set this to a tab with "\t" or perhaps two spaces with " ".
30 Indent string
31
32 // MaxDepth controls the maximum number of levels to descend into nested
33 // data structures. The default, 0, means there is no limit.
34 //
35 // NOTE: Circular data structures are properly detected, so it is not
36 // necessary to set this value unless you specifically want to limit deeply
37 // nested data structures.
38 MaxDepth int
39
40 // DisableMethods specifies whether or not error and fmt.Stringer
41 // interfaces are invoked for types that implement them.
42 DisableMethods bool
43
44 // DisablePointerMethods specifies whether or not to check for and invoke
45 // error and fmt.Stringer interfaces on types which only accept a pointer
46 // receiver when the current type is not a pointer.
47 //
48 // NOTE: This might be an unsafe action since calling one of these methods
49 // with a pointer receiver could technically mutate the value, however,
50 // in practice, types which choose to satisfy an error or fmt.Stringer
51 // interface with a pointer receiver should not be mutating their state
52 // inside these interface methods. As a result, this option relies on
53 // access to the unsafe package, so it will not have any effect when
54 // running in environments without access to the unsafe package such as
55 // Google App Engine or with the "safe" build tag specified.
56 DisablePointerMethods bool
57
58 // DisablePointerAddresses specifies whether to disable the printing of
59 // pointer addresses. This is useful when diffing data structures in tests.
60 DisablePointerAddresses bool
61
62 // EnableCapacities specifies whether to enable the printing of capacities
63 // for arrays, slices and channels.
64 EnableCapacities bool
65 }
66
67 // Config is the active configuration of the top-level functions.
68 // The configuration can be changed by modifying the contents of spew.Config.
69 var Config = ConfigState{Indent: " "}