Skip to content

Commit 3dce331

Browse files
committed
chore: format all files with go fmt
1 parent cfca3c7 commit 3dce331

9 files changed

Lines changed: 108 additions & 94 deletions

File tree

internal/spew/bypass.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// tag is deprecated and thus should not be used.
1919
// Go versions prior to 1.4 are disabled because they use a different layout
2020
// for interfaces which make the implementation of unsafeReflectValue more complex.
21+
//go:build !js && !appengine && !safe && !disableunsafe && go1.4
2122
// +build !js,!appengine,!safe,!disableunsafe,go1.4
2223

2324
package spew

internal/spew/bypasssafe.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// when the code is running on Google App Engine, compiled by GopherJS, or
1717
// "-tags safe" is added to the go build command line. The "disableunsafe"
1818
// tag is deprecated and thus should not be used.
19+
//go:build js || appengine || safe || disableunsafe || !go1.4
1920
// +build js appengine safe disableunsafe !go1.4
2021

2122
package spew

internal/spew/config.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,15 +254,15 @@ pointer addresses used to indirect to the final value. It provides the
254254
following features over the built-in printing facilities provided by the fmt
255255
package:
256256
257-
* Pointers are dereferenced and followed
258-
* Circular data structures are detected and handled properly
259-
* Custom Stringer/error interfaces are optionally invoked, including
260-
on unexported types
261-
* Custom types which only implement the Stringer/error interfaces via
262-
a pointer receiver are optionally invoked when passing non-pointer
263-
variables
264-
* Byte arrays and slices are dumped like the hexdump -C command which
265-
includes offsets, byte values in hex, and ASCII output
257+
- Pointers are dereferenced and followed
258+
- Circular data structures are detected and handled properly
259+
- Custom Stringer/error interfaces are optionally invoked, including
260+
on unexported types
261+
- Custom types which only implement the Stringer/error interfaces via
262+
a pointer receiver are optionally invoked when passing non-pointer
263+
variables
264+
- Byte arrays and slices are dumped like the hexdump -C command which
265+
includes offsets, byte values in hex, and ASCII output
266266
267267
The configuration options are controlled by modifying the public members
268268
of c. See ConfigState for options documentation.
@@ -295,12 +295,12 @@ func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{})
295295

296296
// NewDefaultConfig returns a ConfigState with the following default settings.
297297
//
298-
// Indent: " "
299-
// MaxDepth: 0
300-
// DisableMethods: false
301-
// DisablePointerMethods: false
302-
// ContinueOnMethod: false
303-
// SortKeys: false
298+
// Indent: " "
299+
// MaxDepth: 0
300+
// DisableMethods: false
301+
// DisablePointerMethods: false
302+
// ContinueOnMethod: false
303+
// SortKeys: false
304304
func NewDefaultConfig() *ConfigState {
305305
return &ConfigState{Indent: " "}
306306
}

internal/spew/doc.go

Lines changed: 76 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -21,35 +21,36 @@ debugging.
2121
A quick overview of the additional features spew provides over the built-in
2222
printing facilities for Go data types are as follows:
2323
24-
* Pointers are dereferenced and followed
25-
* Circular data structures are detected and handled properly
26-
* Custom Stringer/error interfaces are optionally invoked, including
27-
on unexported types
28-
* Custom types which only implement the Stringer/error interfaces via
29-
a pointer receiver are optionally invoked when passing non-pointer
30-
variables
31-
* Byte arrays and slices are dumped like the hexdump -C command which
32-
includes offsets, byte values in hex, and ASCII output (only when using
33-
Dump style)
24+
- Pointers are dereferenced and followed
25+
- Circular data structures are detected and handled properly
26+
- Custom Stringer/error interfaces are optionally invoked, including
27+
on unexported types
28+
- Custom types which only implement the Stringer/error interfaces via
29+
a pointer receiver are optionally invoked when passing non-pointer
30+
variables
31+
- Byte arrays and slices are dumped like the hexdump -C command which
32+
includes offsets, byte values in hex, and ASCII output (only when using
33+
Dump style)
3434
3535
There are two different approaches spew allows for dumping Go data structures:
3636
37-
* Dump style which prints with newlines, customizable indentation,
38-
and additional debug information such as types and all pointer addresses
39-
used to indirect to the final value
40-
* A custom Formatter interface that integrates cleanly with the standard fmt
41-
package and replaces %v, %+v, %#v, and %#+v to provide inline printing
42-
similar to the default %v while providing the additional functionality
43-
outlined above and passing unsupported format verbs such as %x and %q
44-
along to fmt
37+
- Dump style which prints with newlines, customizable indentation,
38+
and additional debug information such as types and all pointer addresses
39+
used to indirect to the final value
40+
- A custom Formatter interface that integrates cleanly with the standard fmt
41+
package and replaces %v, %+v, %#v, and %#+v to provide inline printing
42+
similar to the default %v while providing the additional functionality
43+
outlined above and passing unsupported format verbs such as %x and %q
44+
along to fmt
4545
46-
Quick Start
46+
# Quick Start
4747
4848
This section demonstrates how to quickly get started with spew. See the
4949
sections below for further details on formatting and configuration options.
5050
5151
To dump a variable with full newlines, indentation, type, and pointer
5252
information use Dump, Fdump, or Sdump:
53+
5354
spew.Dump(myVar1, myVar2, ...)
5455
spew.Fdump(someWriter, myVar1, myVar2, ...)
5556
str := spew.Sdump(myVar1, myVar2, ...)
@@ -58,12 +59,13 @@ Alternatively, if you would prefer to use format strings with a compacted inline
5859
printing style, use the convenience wrappers Printf, Fprintf, etc with
5960
%v (most compact), %+v (adds pointer addresses), %#v (adds types), or
6061
%#+v (adds types and pointer addresses):
62+
6163
spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
6264
spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
6365
spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
6466
spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
6567
66-
Configuration Options
68+
# Configuration Options
6769
6870
Configuration of spew is handled by fields in the ConfigState type. For
6971
convenience, all of the top-level functions use a global state available
@@ -74,51 +76,52 @@ equivalent to the top-level functions. This allows concurrent configuration
7476
options. See the ConfigState documentation for more details.
7577
7678
The following configuration options are available:
77-
* Indent
78-
String to use for each indentation level for Dump functions.
79-
It is a single space by default. A popular alternative is "\t".
80-
81-
* MaxDepth
82-
Maximum number of levels to descend into nested data structures.
83-
There is no limit by default.
84-
85-
* DisableMethods
86-
Disables invocation of error and Stringer interface methods.
87-
Method invocation is enabled by default.
88-
89-
* DisablePointerMethods
90-
Disables invocation of error and Stringer interface methods on types
91-
which only accept pointer receivers from non-pointer variables.
92-
Pointer method invocation is enabled by default.
93-
94-
* DisablePointerAddresses
95-
DisablePointerAddresses specifies whether to disable the printing of
96-
pointer addresses. This is useful when diffing data structures in tests.
97-
98-
* DisableCapacities
99-
DisableCapacities specifies whether to disable the printing of
100-
capacities for arrays, slices, maps and channels. This is useful when
101-
diffing data structures in tests.
102-
103-
* ContinueOnMethod
104-
Enables recursion into types after invoking error and Stringer interface
105-
methods. Recursion after method invocation is disabled by default.
106-
107-
* SortKeys
108-
Specifies map keys should be sorted before being printed. Use
109-
this to have a more deterministic, diffable output. Note that
110-
only native types (bool, int, uint, floats, uintptr and string)
111-
and types which implement error or Stringer interfaces are
112-
supported with other types sorted according to the
113-
reflect.Value.String() output which guarantees display
114-
stability. Natural map order is used by default.
115-
116-
* SpewKeys
117-
Specifies that, as a last resort attempt, map keys should be
118-
spewed to strings and sorted by those strings. This is only
119-
considered if SortKeys is true.
120-
121-
Dump Usage
79+
80+
- Indent
81+
String to use for each indentation level for Dump functions.
82+
It is a single space by default. A popular alternative is "\t".
83+
84+
- MaxDepth
85+
Maximum number of levels to descend into nested data structures.
86+
There is no limit by default.
87+
88+
- DisableMethods
89+
Disables invocation of error and Stringer interface methods.
90+
Method invocation is enabled by default.
91+
92+
- DisablePointerMethods
93+
Disables invocation of error and Stringer interface methods on types
94+
which only accept pointer receivers from non-pointer variables.
95+
Pointer method invocation is enabled by default.
96+
97+
- DisablePointerAddresses
98+
DisablePointerAddresses specifies whether to disable the printing of
99+
pointer addresses. This is useful when diffing data structures in tests.
100+
101+
- DisableCapacities
102+
DisableCapacities specifies whether to disable the printing of
103+
capacities for arrays, slices, maps and channels. This is useful when
104+
diffing data structures in tests.
105+
106+
- ContinueOnMethod
107+
Enables recursion into types after invoking error and Stringer interface
108+
methods. Recursion after method invocation is disabled by default.
109+
110+
- SortKeys
111+
Specifies map keys should be sorted before being printed. Use
112+
this to have a more deterministic, diffable output. Note that
113+
only native types (bool, int, uint, floats, uintptr and string)
114+
and types which implement error or Stringer interfaces are
115+
supported with other types sorted according to the
116+
reflect.Value.String() output which guarantees display
117+
stability. Natural map order is used by default.
118+
119+
- SpewKeys
120+
Specifies that, as a last resort attempt, map keys should be
121+
spewed to strings and sorted by those strings. This is only
122+
considered if SortKeys is true.
123+
124+
# Dump Usage
122125
123126
Simply call spew.Dump with a list of variables you want to dump:
124127
@@ -133,7 +136,7 @@ A third option is to call spew.Sdump to get the formatted output as a string:
133136
134137
str := spew.Sdump(myVar1, myVar2, ...)
135138
136-
Sample Dump Output
139+
# Sample Dump Output
137140
138141
See the Dump example for details on the setup of the types and variables being
139142
shown here.
@@ -150,13 +153,14 @@ shown here.
150153
151154
Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C
152155
command as shown.
156+
153157
([]uint8) (len=32 cap=32) {
154158
00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
155159
00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
156160
00000020 31 32 |12|
157161
}
158162
159-
Custom Formatter
163+
# Custom Formatter
160164
161165
Spew provides a custom formatter that implements the fmt.Formatter interface
162166
so that it integrates cleanly with standard fmt package printing functions. The
@@ -170,7 +174,7 @@ standard fmt package for formatting. In addition, the custom formatter ignores
170174
the width and precision arguments (however they will still work on the format
171175
specifiers not handled by the custom formatter).
172176
173-
Custom Formatter Usage
177+
# Custom Formatter Usage
174178
175179
The simplest way to make use of the spew custom formatter is to call one of the
176180
convenience functions such as spew.Printf, spew.Println, or spew.Printf. The
@@ -184,15 +188,17 @@ functions have syntax you are most likely already familiar with:
184188
185189
See the Index for the full list convenience functions.
186190
187-
Sample Formatter Output
191+
# Sample Formatter Output
188192
189193
Double pointer to a uint8:
194+
190195
%v: <**>5
191196
%+v: <**>(0xf8400420d0->0xf8400420c8)5
192197
%#v: (**uint8)5
193198
%#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5
194199
195200
Pointer to circular struct with a uint8 field and a pointer to itself:
201+
196202
%v: <*>{1 <*><shown>}
197203
%+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)<shown>}
198204
%#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)<shown>}
@@ -201,7 +207,7 @@ Pointer to circular struct with a uint8 field and a pointer to itself:
201207
See the Printf example for details on the setup of variables being shown
202208
here.
203209
204-
Errors
210+
# Errors
205211
206212
Since it is possible for custom Stringer/error interfaces to panic, spew
207213
detects them and handles them internally by printing the panic information

internal/spew/dump.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -488,15 +488,15 @@ pointer addresses used to indirect to the final value. It provides the
488488
following features over the built-in printing facilities provided by the fmt
489489
package:
490490
491-
* Pointers are dereferenced and followed
492-
* Circular data structures are detected and handled properly
493-
* Custom Stringer/error interfaces are optionally invoked, including
494-
on unexported types
495-
* Custom types which only implement the Stringer/error interfaces via
496-
a pointer receiver are optionally invoked when passing non-pointer
497-
variables
498-
* Byte arrays and slices are dumped like the hexdump -C command which
499-
includes offsets, byte values in hex, and ASCII output
491+
- Pointers are dereferenced and followed
492+
- Circular data structures are detected and handled properly
493+
- Custom Stringer/error interfaces are optionally invoked, including
494+
on unexported types
495+
- Custom types which only implement the Stringer/error interfaces via
496+
a pointer receiver are optionally invoked when passing non-pointer
497+
variables
498+
- Byte arrays and slices are dumped like the hexdump -C command which
499+
includes offsets, byte values in hex, and ASCII output
500500
501501
The configuration options are controlled by an exported package global,
502502
spew.Config. See ConfigState for options documentation.

internal/spew/dumpcgo_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
// does not require cgo to run even though it does handle certain cgo types
2020
// specially. Rather than forcing all clients to require cgo and an external
2121
// C compiler just to run the tests, this scheme makes them optional.
22+
//
23+
//go:build cgo && testcgo
2224
// +build cgo,testcgo
2325

2426
package spew_test

internal/spew/dumpnocgo_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// when either cgo is not supported or "-tags testcgo" is not added to the go
1717
// test command line. This file intentionally does not setup any cgo tests in
1818
// this scenario.
19+
//go:build !cgo || !testcgo
1920
// +build !cgo !testcgo
2021

2122
package spew_test

internal/spew/internalunsafe_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
// when the code is not running on Google App Engine, compiled by GopherJS, and
1717
// "-tags safe" is not added to the go build command line. The "disableunsafe"
1818
// tag is deprecated and thus should not be used.
19+
//go:build !js && !appengine && !safe && !disableunsafe && go1.4
1920
// +build !js,!appengine,!safe,!disableunsafe,go1.4
2021

2122
/*

internal/spew/testdata/dumpcgo.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
// certain cgo types specially. Rather than forcing all clients to require cgo
2222
// and an external C compiler just to run the tests, this scheme makes them
2323
// optional.
24+
//
25+
//go:build cgo && testcgo
2426
// +build cgo,testcgo
2527

2628
package testdata

0 commit comments

Comments
 (0)