Skip to content

Commit

Permalink
all: gofmt
Browse files Browse the repository at this point in the history
Gofmt to update doc comments to the new formatting.

For golang/go#51082.

Change-Id: Iac828c845b6d7ae0eab93fcf007f3ef8e16c8ed7
Reviewed-on: https://go-review.googlesource.com/c/exp/+/399614
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
  • Loading branch information
rsc authored and gopherbot committed Apr 14, 2022
1 parent 7b9b53b commit bcd2187
Show file tree
Hide file tree
Showing 85 changed files with 578 additions and 478 deletions.
17 changes: 10 additions & 7 deletions apidiff/compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ func unexportedMethod(t *types.Interface) *types.Func {
}

// We need to check three things for structs:
// 1. The set of exported fields must be compatible. This ensures that keyed struct
// literals continue to compile. (There is no compatibility guarantee for unkeyed
// struct literals.)
// 2. The set of exported *selectable* fields must be compatible. This includes the exported
// fields of all embedded structs. This ensures that selections continue to compile.
// 3. If the old struct is comparable, so must the new one be. This ensures that equality
// expressions and uses of struct values as map keys continue to compile.
//
// 1. The set of exported fields must be compatible. This ensures that keyed struct
// literals continue to compile. (There is no compatibility guarantee for unkeyed
// struct literals.)
//
// 2. The set of exported *selectable* fields must be compatible. This includes the exported
// fields of all embedded structs. This ensures that selections continue to compile.
//
// 3. If the old struct is comparable, so must the new one be. This ensures that equality
// expressions and uses of struct values as map keys continue to compile.
//
// An unexported embedded struct can't appear in a struct literal outside the
// package, so it doesn't have to be present, or have the same name, in the new
Expand Down
11 changes: 6 additions & 5 deletions apidiff/testdata/exported_fields/ef.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package exported_fields

// Used for testing exportedFields.
// Its exported fields are:
// A1 [1]int
// D bool
// E int
// F F
// S *S
//
// A1 [1]int
// D bool
// E int
// F F
// S *S
type (
S struct {
int
Expand Down
53 changes: 28 additions & 25 deletions apidiff/testdata/tests.go
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
// This file is split into two packages, old and new.
// It is syntactically valid Go so that gofmt can process it.
//
// If a comment begins with: Then:
// old write subsequent lines to the "old" package
// new write subsequent lines to the "new" package
// both write subsequent lines to both packages
// c expect a compatible error with the following text
// i expect an incompatible error with the following text
// If a comment begins with: Then:
// old write subsequent lines to the "old" package
// new write subsequent lines to the "new" package
// both write subsequent lines to both packages
// c expect a compatible error with the following text
// i expect an incompatible error with the following text
package ignore

// both
import "io"

//////////////// Basics

//// Same type in both: OK.
// Same type in both: OK.
// both
type A int

//// Changing the type is an incompatible change.
// Changing the type is an incompatible change.
// old
type B int

// new
// i B: changed from int to string
type B string

//// Adding a new type, whether alias or not, is a compatible change.
// Adding a new type, whether alias or not, is a compatible change.
// new
// c AA: added
type AA = A

// c B1: added
type B1 bool

//// Change of type for an unexported name doesn't matter...
// Change of type for an unexported name doesn't matter...
// old
type t int

// new
type t string // OK: t isn't part of the API

//// ...unless it is exposed.
// ...unless it is exposed.
// both
var V2 u

Expand All @@ -52,7 +52,7 @@ type u string
// i u: changed from string to int
type u int

//// An exposed, unexported type can be renamed.
// An exposed, unexported type can be renamed.
// both
type u2 int

Expand All @@ -64,7 +64,7 @@ var V5 u1
// new
var V5 u2 // OK: V5 has changed type, but old u1 corresopnds to new u2

//// Splitting a single type into two is an incompatible change.
// Splitting a single type into two is an incompatible change.
// both
type u3 int

Expand All @@ -83,7 +83,7 @@ type (
Split2 = u3
)

//// Merging two types into one is OK.
// Merging two types into one is OK.
// old
type (
GoodMerge1 = u2
Expand All @@ -96,7 +96,7 @@ type (
GoodMerge2 = u3
)

//// Merging isn't OK here because a method is lost.
// Merging isn't OK here because a method is lost.
// both
type u4 int

Expand Down Expand Up @@ -125,7 +125,7 @@ type Rem int

//////////////// Constants

//// type changes
// type changes
// old
const (
C1 = 1
Expand Down Expand Up @@ -172,7 +172,7 @@ const (

//////////////// Variables

//// simple type changes
// simple type changes
// old
var (
V1 string
Expand All @@ -189,7 +189,7 @@ var (
V7 chan int
)

//// interface type changes
// interface type changes
// old
var (
V9 interface{ M() }
Expand All @@ -210,7 +210,7 @@ var (
V11 interface{ M(int) }
)

//// struct type changes
// struct type changes
// old
var (
VS1 struct{ A, B int }
Expand Down Expand Up @@ -413,7 +413,8 @@ type I5 = io.Writer
// i I5: changed from io.Writer to I5
// In old, I5 and io.Writer are the same type; in new,
// they are different. That can break something like:
// var _ func(io.Writer) = func(pkg.I6) {}
//
// var _ func(io.Writer) = func(pkg.I6) {}
type I5 io.Writer

// old
Expand Down Expand Up @@ -471,7 +472,9 @@ type t4 int

// i VT4: changed from int to t4
// This is incompatible because of code like
// VT4 + int(1)
//
// VT4 + int(1)
//
// which works in old but fails in new.
// The difference from the above cases is that
// in those, we were merging two types into one;
Expand Down Expand Up @@ -627,7 +630,7 @@ type S4 struct {
*S4 // OK: same (recursive embedding)
}

//// Difference between exported selectable fields and exported immediate fields.
// Difference between exported selectable fields and exported immediate fields.
// both
type S5 struct{ A int }

Expand All @@ -648,7 +651,7 @@ type S6 struct {
S5
}

//// Ambiguous fields can exist; they just can't be selected.
// Ambiguous fields can exist; they just can't be selected.
// both
type (
embed7a struct{ E int }
Expand Down Expand Up @@ -870,7 +873,7 @@ type H interface {

//// Splitting types

//// OK: in both old and new, {J1, K1, L1} name the same type.
// OK: in both old and new, {J1, K1, L1} name the same type.
// old
type (
J1 = K1
Expand All @@ -885,7 +888,7 @@ type (
L1 = J1
)

//// Old has one type, K2; new has J2 and K2.
// Old has one type, K2; new has J2 and K2.
// both
type K2 int

Expand Down
18 changes: 9 additions & 9 deletions cmd/gorelease/gorelease.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@
//
// Usage:
//
// gorelease [-base={version|none}] [-version=version]
// gorelease [-base={version|none}] [-version=version]
//
// Examples:
//
// # Compare with the latest version and suggest a new version.
// gorelease
// # Compare with the latest version and suggest a new version.
// gorelease
//
// # Compare with a specific version and suggest a new version.
// gorelease -base=v1.2.3
// # Compare with a specific version and suggest a new version.
// gorelease -base=v1.2.3
//
// # Compare with the latest version and check a specific new version for compatibility.
// gorelease -version=v1.3.0
// # Compare with the latest version and check a specific new version for compatibility.
// gorelease -version=v1.3.0
//
// # Compare with a specific version and check a specific new version for compatibility.
// gorelease -base=v1.2.3 -version=v1.3.0
// # Compare with a specific version and check a specific new version for compatibility.
// gorelease -base=v1.2.3 -version=v1.3.0
//
// gorelease analyzes changes in the public API and dependencies of the main
// module. It compares a base version (set with -base) with the currently
Expand Down
10 changes: 5 additions & 5 deletions cmd/macos-roots-test/root_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ var debugDarwinRoots = true
//
// The strategy is as follows:
//
// 1. Run "security find-certificate" to dump the list of system root
// CAs in PEM format.
// 1. Run "security find-certificate" to dump the list of system root
// CAs in PEM format.
//
// 2. For each dumped cert, conditionally verify it with "security
// verify-cert" if that cert was not in the SystemRootCertificates
// keychain, which can't have custom trust policies.
// 2. For each dumped cert, conditionally verify it with "security
// verify-cert" if that cert was not in the SystemRootCertificates
// keychain, which can't have custom trust policies.
//
// We need to run "verify-cert" for all certificates not in SystemRootCertificates
// because there might be certificates in the keychains without a corresponding
Expand Down
5 changes: 2 additions & 3 deletions cmd/txtar/txtar.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@
//
// Example usage:
//
// txtar *.go <README >testdata/example.txt
//
// txtar --extract <playground_example.txt >main.go
// txtar *.go <README >testdata/example.txt
//
// txtar --extract <playground_example.txt >main.go
package main

import (
Expand Down
8 changes: 3 additions & 5 deletions ebnf/ebnf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
// non-terminal productions (i.e., productions which allow white-space
// and comments between tokens); all other production names denote
// lexical productions.
//
package ebnf // import "golang.org/x/exp/ebnf"

import (
Expand Down Expand Up @@ -256,12 +255,11 @@ func (v *verifier) verify(grammar Grammar, start string) {
}

// Verify checks that:
// - all productions used are defined
// - all productions defined are used when beginning at start
// - lexical productions refer only to other lexical productions
// - all productions used are defined
// - all productions defined are used when beginning at start
// - lexical productions refer only to other lexical productions
//
// Position information is interpreted relative to the file set fset.
//
func Verify(grammar Grammar, start string) error {
var v verifier
v.verify(grammar, start)
Expand Down
1 change: 0 additions & 1 deletion ebnf/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ func (p *parser) parse(filename string, src io.Reader) Grammar {
// for incorrect syntax and if a production is declared
// more than once; the filename is used only for error
// positions.
//
func Parse(filename string, src io.Reader) (Grammar, error) {
var p parser
grammar := p.parse(filename, src)
Expand Down
5 changes: 2 additions & 3 deletions ebnflint/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
// license that can be found in the LICENSE file.

/*
Ebnflint verifies that EBNF productions are consistent and grammatically correct.
It reads them from an HTML document such as the Go specification.
Grammar productions are grouped in boxes demarcated by the HTML elements
<pre class="ebnf">
</pre>
Usage:
go tool ebnflint [--start production] [file]
The --start flag specifies the name of the start production for
the grammar; it defaults to "Start".
*/
package main // import "golang.org/x/exp/ebnflint"
3 changes: 2 additions & 1 deletion errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
// Package errors implements functions to manipulate errors.
//
// This package implements the Go 2 draft designs for error inspection and printing:
// https://go.googlesource.com/proposal/+/master/design/go2draft.md
//
// https://go.googlesource.com/proposal/+/master/design/go2draft.md
//
// This is an EXPERIMENTAL package, and may change in arbitrary ways without notice.
package errors
Expand Down
Loading

0 comments on commit bcd2187

Please sign in to comment.