Skip to content

Commit 1930977

Browse files
committed
all: gofmt main repo
[This CL is part of a sequence implementing the proposal golang#51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For golang#51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 0179331 commit 1930977

File tree

373 files changed

+3242
-2536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

373 files changed

+3242
-2536
lines changed

misc/cgo/gmp/gmp.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,9 @@ func (z *Int) Abs(x *Int) *Int {
333333

334334
// CmpInt compares x and y. The result is
335335
//
336-
// -1 if x < y
337-
// 0 if x == y
338-
// +1 if x > y
339-
//
336+
// -1 if x < y
337+
// 0 if x == y
338+
// +1 if x > y
340339
func CmpInt(x, y *Int) int {
341340
x.doinit()
342341
y.doinit()

misc/ios/go_ios_exec.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
// binary.
1414
//
1515
// This script requires that three environment variables be set:
16-
// GOIOS_DEV_ID: The codesigning developer id or certificate identifier
17-
// GOIOS_APP_ID: The provisioning app id prefix. Must support wildcard app ids.
18-
// GOIOS_TEAM_ID: The team id that owns the app id prefix.
16+
//
17+
// GOIOS_DEV_ID: The codesigning developer id or certificate identifier
18+
// GOIOS_APP_ID: The provisioning app id prefix. Must support wildcard app ids.
19+
// GOIOS_TEAM_ID: The team id that owns the app id prefix.
20+
//
1921
// $GOROOT/misc/ios contains a script, detect.go, that attempts to autodetect these.
2022
package main
2123

src/archive/tar/common.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@ func (s sparseEntry) endOffset() int64 { return s.Offset + s.Length }
221221
// that the file has no data in it, which is rather odd.
222222
//
223223
// As an example, if the underlying raw file contains the 10-byte data:
224+
//
224225
// var compactFile = "abcdefgh"
225226
//
226227
// And the sparse map has the following entries:
228+
//
227229
// var spd sparseDatas = []sparseEntry{
228230
// {Offset: 2, Length: 5}, // Data fragment for 2..6
229231
// {Offset: 18, Length: 3}, // Data fragment for 18..20
@@ -235,6 +237,7 @@ func (s sparseEntry) endOffset() int64 { return s.Offset + s.Length }
235237
// }
236238
//
237239
// Then the content of the resulting sparse file with a Header.Size of 25 is:
240+
//
238241
// var sparseFile = "\x00"*2 + "abcde" + "\x00"*11 + "fgh" + "\x00"*4
239242
type (
240243
sparseDatas []sparseEntry
@@ -293,9 +296,9 @@ func alignSparseEntries(src []sparseEntry, size int64) []sparseEntry {
293296
// The input must have been already validated.
294297
//
295298
// This function mutates src and returns a normalized map where:
296-
// * adjacent fragments are coalesced together
297-
// * only the last fragment may be empty
298-
// * the endOffset of the last fragment is the total size
299+
// - adjacent fragments are coalesced together
300+
// - only the last fragment may be empty
301+
// - the endOffset of the last fragment is the total size
299302
func invertSparseEntries(src []sparseEntry, size int64) []sparseEntry {
300303
dst := src[:0]
301304
var pre sparseEntry

src/archive/tar/reader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,9 @@ func parsePAX(r io.Reader) (map[string]string, error) {
336336
// header in case further processing is required.
337337
//
338338
// The err will be set to io.EOF only when one of the following occurs:
339-
// * Exactly 0 bytes are read and EOF is hit.
340-
// * Exactly 1 block of zeros is read and EOF is hit.
341-
// * At least 2 blocks of zeros are read.
339+
// - Exactly 0 bytes are read and EOF is hit.
340+
// - Exactly 1 block of zeros is read and EOF is hit.
341+
// - At least 2 blocks of zeros are read.
342342
func (tr *Reader) readHeader() (*Header, *block, error) {
343343
// Two blocks of zero bytes marks the end of the archive.
344344
if _, err := io.ReadFull(tr.r, tr.blk[:]); err != nil {

src/archive/tar/strconv.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ func formatPAXRecord(k, v string) (string, error) {
306306

307307
// validPAXRecord reports whether the key-value pair is valid where each
308308
// record is formatted as:
309+
//
309310
// "%d %s=%s\n" % (size, key, value)
310311
//
311312
// Keys and values should be UTF-8, but the number of bad writers out there

src/builtin/builtin.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ type ComplexType complex64
137137
// new elements. If it does not, a new underlying array will be allocated.
138138
// Append returns the updated slice. It is therefore necessary to store the
139139
// result of append, often in the variable holding the slice itself:
140+
//
140141
// slice = append(slice, elem1, elem2)
141142
// slice = append(slice, anotherSlice...)
143+
//
142144
// As a special case, it is legal to append a string to a byte slice, like this:
145+
//
143146
// slice = append([]byte("hello "), "world"...)
144147
func append(slice []Type, elems ...Type) []Type
145148

@@ -156,24 +159,28 @@ func copy(dst, src []Type) int
156159
func delete(m map[Type]Type1, key Type)
157160

158161
// The len built-in function returns the length of v, according to its type:
162+
//
159163
// Array: the number of elements in v.
160164
// Pointer to array: the number of elements in *v (even if v is nil).
161165
// Slice, or map: the number of elements in v; if v is nil, len(v) is zero.
162166
// String: the number of bytes in v.
163167
// Channel: the number of elements queued (unread) in the channel buffer;
164168
// if v is nil, len(v) is zero.
169+
//
165170
// For some arguments, such as a string literal or a simple array expression, the
166171
// result can be a constant. See the Go language specification's "Length and
167172
// capacity" section for details.
168173
func len(v Type) int
169174

170175
// The cap built-in function returns the capacity of v, according to its type:
176+
//
171177
// Array: the number of elements in v (same as len(v)).
172178
// Pointer to array: the number of elements in *v (same as len(v)).
173179
// Slice: the maximum length the slice can reach when resliced;
174180
// if v is nil, cap(v) is zero.
175181
// Channel: the channel buffer capacity, in units of elements;
176182
// if v is nil, cap(v) is zero.
183+
//
177184
// For some arguments, such as a simple array expression, the result can be a
178185
// constant. See the Go language specification's "Length and capacity" section for
179186
// details.
@@ -184,6 +191,7 @@ func cap(v Type) int
184191
// value. Unlike new, make's return type is the same as the type of its
185192
// argument, not a pointer to it. The specification of the result depends on
186193
// the type:
194+
//
187195
// Slice: The size specifies the length. The capacity of the slice is
188196
// equal to its length. A second integer argument may be provided to
189197
// specify a different capacity; it must be no smaller than the
@@ -225,7 +233,9 @@ func imag(c ComplexType) FloatType
225233
// the last sent value is received. After the last value has been received
226234
// from a closed channel c, any receive from c will succeed without
227235
// blocking, returning the zero value for the channel element. The form
236+
//
228237
// x, ok := <-c
238+
//
229239
// will also set ok to false for a closed channel.
230240
func close(c chan<- Type)
231241

src/bytes/bytes.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,10 @@ func genSplit(s, sep []byte, sepSave, n int) [][]byte {
372372
// the subslices between those separators.
373373
// If sep is empty, SplitN splits after each UTF-8 sequence.
374374
// The count determines the number of subslices to return:
375-
// n > 0: at most n subslices; the last subslice will be the unsplit remainder.
376-
// n == 0: the result is nil (zero subslices)
377-
// n < 0: all subslices
375+
//
376+
// n > 0: at most n subslices; the last subslice will be the unsplit remainder.
377+
// n == 0: the result is nil (zero subslices)
378+
// n < 0: all subslices
378379
//
379380
// To split around the first instance of a separator, see Cut.
380381
func SplitN(s, sep []byte, n int) [][]byte { return genSplit(s, sep, 0, n) }
@@ -383,9 +384,10 @@ func SplitN(s, sep []byte, n int) [][]byte { return genSplit(s, sep, 0, n) }
383384
// returns a slice of those subslices.
384385
// If sep is empty, SplitAfterN splits after each UTF-8 sequence.
385386
// The count determines the number of subslices to return:
386-
// n > 0: at most n subslices; the last subslice will be the unsplit remainder.
387-
// n == 0: the result is nil (zero subslices)
388-
// n < 0: all subslices
387+
//
388+
// n > 0: at most n subslices; the last subslice will be the unsplit remainder.
389+
// n == 0: the result is nil (zero subslices)
390+
// n < 0: all subslices
389391
func SplitAfterN(s, sep []byte, n int) [][]byte {
390392
return genSplit(s, sep, len(sep), n)
391393
}

src/cmd/addr2line/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// just enough to support pprof.
77
//
88
// Usage:
9+
//
910
// go tool addr2line binary
1011
//
1112
// Addr2line reads hexadecimal addresses, one per line and with optional 0x prefix,

src/cmd/asm/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// license that can be found in the LICENSE file.
44

55
/*
6-
Asm, typically invoked as ``go tool asm'', assembles the source file into an object
6+
Asm, typically invoked as go tool asm, assembles the source file into an object
77
file named for the basename of the argument source file with a .o suffix. The
88
object file can then be combined with other objects into a package archive.
99
10-
Command Line
10+
# Command Line
1111
1212
Usage:
1313

src/cmd/asm/internal/asm/parse.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func (p *Parser) nextToken() lex.ScanToken {
162162

163163
// line consumes a single assembly line from p.lex of the form
164164
//
165-
// {label:} WORD[.cond] [ arg {, arg} ] (';' | '\n')
165+
// {label:} WORD[.cond] [ arg {, arg} ] (';' | '\n')
166166
//
167167
// It adds any labels to p.pendingLabels and returns the word, cond,
168168
// operand list, and true. If there is an error or EOF, it returns
@@ -891,7 +891,7 @@ func (p *Parser) symRefAttrs(name string, issueError bool) (bool, obj.ABI) {
891891
// constrained form of the operand syntax that's always SB-based,
892892
// non-static, and has at most a simple integer offset:
893893
//
894-
// [$|*]sym[<abi>][+Int](SB)
894+
// [$|*]sym[<abi>][+Int](SB)
895895
func (p *Parser) funcAddress() (string, obj.ABI, bool) {
896896
switch p.peek() {
897897
case '$', '*':
@@ -1041,9 +1041,13 @@ func (p *Parser) registerIndirect(a *obj.Addr, prefix rune) {
10411041
//
10421042
// For 386/AMD64 register list specifies 4VNNIW-style multi-source operand.
10431043
// For range of 4 elements, Intel manual uses "+3" notation, for example:
1044+
//
10441045
// VP4DPWSSDS zmm1{k1}{z}, zmm2+3, m128
1046+
//
10451047
// Given asm line:
1048+
//
10461049
// VP4DPWSSDS Z5, [Z10-Z13], (AX)
1050+
//
10471051
// zmm2 is Z10, and Z13 is the only valid value for it (Z10+3).
10481052
// Only simple ranges are accepted, like [Z0-Z3].
10491053
//

src/cmd/buildid/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
Buildid displays or updates the build ID stored in a Go package or binary.
77
88
Usage:
9+
910
go tool buildid [-w] file
1011
1112
By default, buildid prints the build ID found in the named file.

src/cmd/cgo/doc.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
// license that can be found in the LICENSE file.
44

55
/*
6-
76
Cgo enables the creation of Go packages that call C code.
87
9-
Using cgo with the go command
8+
# Using cgo with the go command
109
1110
To use cgo write normal Go code that imports a pseudo-package "C".
1211
The Go code can then refer to types such as C.size_t, variables such
@@ -91,11 +90,11 @@ file. This allows pre-compiled static libraries to be included in the package
9190
directory and linked properly.
9291
For example if package foo is in the directory /go/src/foo:
9392
94-
// #cgo LDFLAGS: -L${SRCDIR}/libs -lfoo
93+
// #cgo LDFLAGS: -L${SRCDIR}/libs -lfoo
9594
9695
Will be expanded to:
9796
98-
// #cgo LDFLAGS: -L/go/src/foo/libs -lfoo
97+
// #cgo LDFLAGS: -L/go/src/foo/libs -lfoo
9998
10099
When the Go tool sees that one or more Go files use the special import
101100
"C", it will look for other non-Go files in the directory and compile
@@ -139,7 +138,7 @@ or you can set the CC environment variable any time you run the go tool.
139138
The CXX_FOR_TARGET, CXX_FOR_${GOOS}_${GOARCH}, and CXX
140139
environment variables work in a similar way for C++ code.
141140
142-
Go references to C
141+
# Go references to C
143142
144143
Within the Go file, C's struct field names that are keywords in Go
145144
can be accessed by prefixing them with an underscore: if x points at a C
@@ -291,7 +290,7 @@ the helper function crashes the program, like when Go itself runs out
291290
of memory. Because C.malloc cannot fail, it has no two-result form
292291
that returns errno.
293292
294-
C references to Go
293+
# C references to Go
295294
296295
Go functions can be exported for use by C code in the following way:
297296
@@ -327,7 +326,7 @@ definitions and declarations, then the two output files will produce
327326
duplicate symbols and the linker will fail. To avoid this, definitions
328327
must be placed in preambles in other files, or in C source files.
329328
330-
Passing pointers
329+
# Passing pointers
331330
332331
Go is a garbage collected language, and the garbage collector needs to
333332
know the location of every pointer to Go memory. Because of this,
@@ -398,7 +397,7 @@ passing uninitialized C memory to Go code if the Go code is going to
398397
store pointer values in it. Zero out the memory in C before passing it
399398
to Go.
400399
401-
Special cases
400+
# Special cases
402401
403402
A few special C types which would normally be represented by a pointer
404403
type in Go are instead represented by a uintptr. Those include:
@@ -449,9 +448,10 @@ to auto-update code from Go 1.14 and earlier:
449448
450449
go tool fix -r eglconf <pkg>
451450
452-
Using cgo directly
451+
# Using cgo directly
453452
454453
Usage:
454+
455455
go tool cgo [cgo options] [-- compiler options] gofiles...
456456
457457
Cgo transforms the specified input Go source files into several output

src/cmd/cgo/gcc.go

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ func (p *Package) addToFlag(flag string, args []string) {
114114
//
115115
// For example, the following string:
116116
//
117-
// `a b:"c d" 'e''f' "g\""`
117+
// `a b:"c d" 'e''f' "g\""`
118118
//
119119
// Would be parsed as:
120120
//
121-
// []string{"a", "b:c d", "ef", `g"`}
121+
// []string{"a", "b:c d", "ef", `g"`}
122122
func splitQuoted(s string) (r []string, err error) {
123123
var args []string
124124
arg := make([]rune, len(s))
@@ -1137,13 +1137,19 @@ func (p *Package) mangle(f *File, arg *ast.Expr, addPosition bool) (ast.Expr, bo
11371137

11381138
// checkIndex checks whether arg has the form &a[i], possibly inside
11391139
// type conversions. If so, then in the general case it writes
1140-
// _cgoIndexNN := a
1141-
// _cgoNN := &cgoIndexNN[i] // with type conversions, if any
1140+
//
1141+
// _cgoIndexNN := a
1142+
// _cgoNN := &cgoIndexNN[i] // with type conversions, if any
1143+
//
11421144
// to sb, and writes
1143-
// _cgoCheckPointer(_cgoNN, _cgoIndexNN)
1145+
//
1146+
// _cgoCheckPointer(_cgoNN, _cgoIndexNN)
1147+
//
11441148
// to sbCheck, and returns true. If a is a simple variable or field reference,
11451149
// it writes
1146-
// _cgoIndexNN := &a
1150+
//
1151+
// _cgoIndexNN := &a
1152+
//
11471153
// and dereferences the uses of _cgoIndexNN. Taking the address avoids
11481154
// making a copy of an array.
11491155
//
@@ -1191,10 +1197,14 @@ func (p *Package) checkIndex(sb, sbCheck *bytes.Buffer, arg ast.Expr, i int) boo
11911197

11921198
// checkAddr checks whether arg has the form &x, possibly inside type
11931199
// conversions. If so, it writes
1194-
// _cgoBaseNN := &x
1195-
// _cgoNN := _cgoBaseNN // with type conversions, if any
1200+
//
1201+
// _cgoBaseNN := &x
1202+
// _cgoNN := _cgoBaseNN // with type conversions, if any
1203+
//
11961204
// to sb, and writes
1197-
// _cgoCheckPointer(_cgoBaseNN, true)
1205+
//
1206+
// _cgoCheckPointer(_cgoBaseNN, true)
1207+
//
11981208
// to sbCheck, and returns true. This tells _cgoCheckPointer to check
11991209
// just the contents of the pointer being passed, not any other part
12001210
// of the memory allocation. This is run after checkIndex, which looks

src/cmd/compile/internal/amd64/ssa.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ func moveByType(t *types.Type) obj.As {
111111
}
112112

113113
// opregreg emits instructions for
114-
// dest := dest(To) op src(From)
114+
//
115+
// dest := dest(To) op src(From)
116+
//
115117
// and also returns the created obj.Prog so it
116118
// may be further adjusted (offset, scale, etc).
117119
func opregreg(s *ssagen.State, op obj.As, dest, src int16) *obj.Prog {

src/cmd/compile/internal/inline/inl.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ func InlineCalls(fn *ir.Func) {
522522
// but then you may as well do it here. so this is cleaner and
523523
// shorter and less complicated.
524524
// The result of inlnode MUST be assigned back to n, e.g.
525-
// n.Left = inlnode(n.Left)
525+
//
526+
// n.Left = inlnode(n.Left)
526527
func inlnode(n ir.Node, maxCost int32, inlMap map[*ir.Func]bool, edit func(ir.Node) ir.Node) ir.Node {
527528
if n == nil {
528529
return n
@@ -657,7 +658,8 @@ var NewInline = func(call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCa
657658
// inlined function body, and (List, Rlist) contain the (input, output)
658659
// parameters.
659660
// The result of mkinlcall MUST be assigned back to n, e.g.
660-
// n.Left = mkinlcall(n.Left, fn, isddd)
661+
//
662+
// n.Left = mkinlcall(n.Left, fn, isddd)
661663
func mkinlcall(n *ir.CallExpr, fn *ir.Func, maxCost int32, inlMap map[*ir.Func]bool, edit func(ir.Node) ir.Node) ir.Node {
662664
if fn.Inl == nil {
663665
if logopt.Enabled() {

0 commit comments

Comments
 (0)