all: gofmt
Gofmt to update doc comments to the new formatting.
(There are so many files in x/tools I am breaking up the
gofmt'ing into multiple CLs. This is the leftovers.)
For golang/go#51082.
Change-Id: Id9d440cde9de7093d2ffe06cbaa7098993823d6b
Reviewed-on: https://go-review.googlesource.com/c/tools/+/399363
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
diff --git a/container/intsets/sparse.go b/container/intsets/sparse.go
index 2f1a0ea..c06aec8 100644
--- a/container/intsets/sparse.go
+++ b/container/intsets/sparse.go
@@ -10,7 +10,6 @@
// space-efficient than equivalent operations on sets based on the Go
// map type. The IsEmpty, Min, Max, Clear and TakeMin operations
// require constant time.
-//
package intsets // import "golang.org/x/tools/container/intsets"
// TODO(adonovan):
@@ -37,7 +36,6 @@
//
// Sparse sets must be copied using the Copy method, not by assigning
// a Sparse value.
-//
type Sparse struct {
// An uninitialized Sparse represents an empty set.
// An empty set may also be represented by
@@ -105,7 +103,6 @@
// is the Euclidean remainder.
//
// A block may only be empty transiently.
-//
type block struct {
offset int // offset mod bitsPerBlock == 0
bits [wordsPerBlock]word // contains at least one set bit
@@ -122,7 +119,6 @@
// insert sets the block b's ith bit and
// returns true if it was not already set.
-//
func (b *block) insert(i uint) bool {
w, mask := wordMask(i)
if b.bits[w]&mask == 0 {
@@ -135,7 +131,6 @@
// remove clears the block's ith bit and
// returns true if the bit was previously set.
// NB: may leave the block empty.
-//
func (b *block) remove(i uint) bool {
w, mask := wordMask(i)
if b.bits[w]&mask != 0 {
@@ -238,7 +233,6 @@
// offsetAndBitIndex returns the offset of the block that would
// contain x and the bit index of x within that block.
-//
func offsetAndBitIndex(x int) (int, uint) {
mod := x % bitsPerBlock
if mod < 0 {
@@ -438,9 +432,8 @@
//
// This method may be used for iteration over a worklist like so:
//
-// var x int
-// for worklist.TakeMin(&x) { use(x) }
-//
+// var x int
+// for worklist.TakeMin(&x) { use(x) }
func (s *Sparse) TakeMin(p *int) bool {
if s.IsEmpty() {
return false
@@ -466,7 +459,6 @@
// f must not mutate s. Consequently, forEach is not safe to expose
// to clients. In any case, using "range s.AppendTo()" allows more
// natural control flow with continue/break/return.
-//
func (s *Sparse) forEach(f func(int)) {
for b := s.first(); b != &none; b = s.next(b) {
b.forEach(f)
@@ -1021,11 +1013,11 @@
// preceded by a digit, appears if the sum is non-integral.
//
// Examples:
-// {}.BitString() = "0"
-// {4,5}.BitString() = "110000"
-// {-3}.BitString() = "0.001"
-// {-3,0,4,5}.BitString() = "110001.001"
//
+// {}.BitString() = "0"
+// {4,5}.BitString() = "110000"
+// {-3}.BitString() = "0.001"
+// {-3,0,4,5}.BitString() = "110001.001"
func (s *Sparse) BitString() string {
if s.IsEmpty() {
return "0"
@@ -1060,7 +1052,6 @@
// GoString returns a string showing the internal representation of
// the set s.
-//
func (s *Sparse) GoString() string {
var buf bytes.Buffer
for b := s.first(); b != &none; b = s.next(b) {
diff --git a/copyright/copyright.go b/copyright/copyright.go
index 4a04d13..eb56ef2 100644
--- a/copyright/copyright.go
+++ b/copyright/copyright.go
@@ -96,6 +96,7 @@
// Copied from golang.org/x/tools/internal/lsp/source/util.go.
// Matches cgo generated comment as well as the proposed standard:
+//
// https://golang.org/s/generatedcode
var generatedRx = regexp.MustCompile(`// .*DO NOT EDIT\.?`)
diff --git a/go/ast/astutil/enclosing.go b/go/ast/astutil/enclosing.go
index a5c6d6d..1d8c401 100644
--- a/go/ast/astutil/enclosing.go
+++ b/go/ast/astutil/enclosing.go
@@ -22,9 +22,9 @@
// additional whitespace abutting a node to be enclosed by it.
// In this example:
//
-// z := x + y // add them
-// <-A->
-// <----B----->
+// z := x + y // add them
+// <-A->
+// <----B----->
//
// the ast.BinaryExpr(+) node is considered to enclose interval B
// even though its [Pos()..End()) is actually only interval A.
@@ -43,10 +43,10 @@
// interior whitespace of path[0].
// In this example:
//
-// z := x + y // add them
-// <--C--> <---E-->
-// ^
-// D
+// z := x + y // add them
+// <--C--> <---E-->
+// ^
+// D
//
// intervals C, D and E are inexact. C is contained by the
// z-assignment statement, because it spans three of its children (:=,
@@ -59,7 +59,6 @@
// Requires FileSet; see loader.tokenFileContainsPos.
//
// Postcondition: path is never nil; it always contains at least 'root'.
-//
func PathEnclosingInterval(root *ast.File, start, end token.Pos) (path []ast.Node, exact bool) {
// fmt.Printf("EnclosingInterval %d %d\n", start, end) // debugging
@@ -162,7 +161,6 @@
// tokenNode is a dummy implementation of ast.Node for a single token.
// They are used transiently by PathEnclosingInterval but never escape
// this package.
-//
type tokenNode struct {
pos token.Pos
end token.Pos
@@ -183,7 +181,6 @@
// childrenOf returns the direct non-nil children of ast.Node n.
// It may include fake ast.Node implementations for bare tokens.
// it is not safe to call (e.g.) ast.Walk on such nodes.
-//
func childrenOf(n ast.Node) []ast.Node {
var children []ast.Node
@@ -488,7 +485,6 @@
// TODO(adonovan): in some cases (e.g. Field, FieldList, Ident,
// StarExpr) we could be much more specific given the path to the AST
// root. Perhaps we should do that.
-//
func NodeDescription(n ast.Node) string {
switch n := n.(type) {
case *ast.ArrayType:
diff --git a/go/ast/astutil/enclosing_test.go b/go/ast/astutil/enclosing_test.go
index 5e86ff9..de96d44 100644
--- a/go/ast/astutil/enclosing_test.go
+++ b/go/ast/astutil/enclosing_test.go
@@ -40,7 +40,6 @@
// findInterval parses input and returns the [start, end) positions of
// the first occurrence of substr in input. f==nil indicates failure;
// an error has already been reported in that case.
-//
func findInterval(t *testing.T, fset *token.FileSet, input, substr string) (f *ast.File, start, end token.Pos) {
f, err := parser.ParseFile(fset, "<input>", input, 0)
if err != nil {
diff --git a/go/ast/astutil/imports.go b/go/ast/astutil/imports.go
index f7413ce..18d1adb 100644
--- a/go/ast/astutil/imports.go
+++ b/go/ast/astutil/imports.go
@@ -22,8 +22,11 @@
// If name is not empty, it is used to rename the import.
//
// For example, calling
+//
// AddNamedImport(fset, f, "pathpkg", "path")
+//
// adds
+//
// import pathpkg "path"
func AddNamedImport(fset *token.FileSet, f *ast.File, name, path string) (added bool) {
if imports(f, name, path) {
diff --git a/go/ast/astutil/rewrite.go b/go/ast/astutil/rewrite.go
index 6d9ca23..729e9c8 100644
--- a/go/ast/astutil/rewrite.go
+++ b/go/ast/astutil/rewrite.go
@@ -41,7 +41,6 @@
// Children are traversed in the order in which they appear in the
// respective node's struct definition. A package's files are
// traversed in the filenames' alphabetical order.
-//
func Apply(root ast.Node, pre, post ApplyFunc) (result ast.Node) {
parent := &struct{ ast.Node }{root}
defer func() {
@@ -65,8 +64,8 @@
// c.Parent(), and f is the field identifier with name c.Name(),
// the following invariants hold:
//
-// p.f == c.Node() if c.Index() < 0
-// p.f[c.Index()] == c.Node() if c.Index() >= 0
+// p.f == c.Node() if c.Index() < 0
+// p.f[c.Index()] == c.Node() if c.Index() >= 0
//
// The methods Replace, Delete, InsertBefore, and InsertAfter
// can be used to change the AST without disrupting Apply.
diff --git a/go/ast/inspector/typeof.go b/go/ast/inspector/typeof.go
index 11f4fc3..11ab2bc 100644
--- a/go/ast/inspector/typeof.go
+++ b/go/ast/inspector/typeof.go
@@ -77,12 +77,14 @@
// typeOf returns a distinct single-bit value that represents the type of n.
//
// Various implementations were benchmarked with BenchmarkNewInspector:
-// GOGC=off
-// - type switch 4.9-5.5ms 2.1ms
-// - binary search over a sorted list of types 5.5-5.9ms 2.5ms
-// - linear scan, frequency-ordered list 5.9-6.1ms 2.7ms
-// - linear scan, unordered list 6.4ms 2.7ms
-// - hash table 6.5ms 3.1ms
+//
+// GOGC=off
+// - type switch 4.9-5.5ms 2.1ms
+// - binary search over a sorted list of types 5.5-5.9ms 2.5ms
+// - linear scan, frequency-ordered list 5.9-6.1ms 2.7ms
+// - linear scan, unordered list 6.4ms 2.7ms
+// - hash table 6.5ms 3.1ms
+//
// A perfect hash seemed like overkill.
//
// The compiler's switch statement is the clear winner
@@ -90,7 +92,6 @@
// with constant conditions and good branch prediction.
// (Sadly it is the most verbose in source code.)
// Binary search suffered from poor branch prediction.
-//
func typeOf(n ast.Node) uint64 {
// Fast path: nearly half of all nodes are identifiers.
if _, ok := n.(*ast.Ident); ok {
diff --git a/go/buildutil/allpackages.go b/go/buildutil/allpackages.go
index c0cb03e..dfb8cd6 100644
--- a/go/buildutil/allpackages.go
+++ b/go/buildutil/allpackages.go
@@ -28,7 +28,6 @@
//
// All I/O is done via the build.Context file system interface,
// which must be concurrency-safe.
-//
func AllPackages(ctxt *build.Context) []string {
var list []string
ForEachPackage(ctxt, func(pkg string, _ error) {
@@ -48,7 +47,6 @@
//
// All I/O is done via the build.Context file system interface,
// which must be concurrency-safe.
-//
func ForEachPackage(ctxt *build.Context, found func(importPath string, err error)) {
ch := make(chan item)
@@ -127,19 +125,18 @@
// ExpandPatterns returns the set of packages matched by patterns,
// which may have the following forms:
//
-// golang.org/x/tools/cmd/guru # a single package
-// golang.org/x/tools/... # all packages beneath dir
-// ... # the entire workspace.
+// golang.org/x/tools/cmd/guru # a single package
+// golang.org/x/tools/... # all packages beneath dir
+// ... # the entire workspace.
//
// Order is significant: a pattern preceded by '-' removes matching
// packages from the set. For example, these patterns match all encoding
// packages except encoding/xml:
//
-// encoding/... -encoding/xml
+// encoding/... -encoding/xml
//
// A trailing slash in a pattern is ignored. (Path components of Go
// package names are separated by slash, not the platform's path separator.)
-//
func ExpandPatterns(ctxt *build.Context, patterns []string) map[string]bool {
// TODO(adonovan): support other features of 'go list':
// - "std"/"cmd"/"all" meta-packages
diff --git a/go/buildutil/fakecontext.go b/go/buildutil/fakecontext.go
index 5fc672f..15025f6 100644
--- a/go/buildutil/fakecontext.go
+++ b/go/buildutil/fakecontext.go
@@ -30,7 +30,6 @@
// /go/src/ including, for instance, "math" and "math/big".
// ReadDir("/go/src/math/big") would return all the files in the
// "math/big" package.
-//
func FakeContext(pkgs map[string]map[string]string) *build.Context {
clean := func(filename string) string {
f := path.Clean(filepath.ToSlash(filename))
diff --git a/go/buildutil/overlay.go b/go/buildutil/overlay.go
index 8e23908..bdbfd93 100644
--- a/go/buildutil/overlay.go
+++ b/go/buildutil/overlay.go
@@ -60,8 +60,7 @@
// ParseOverlayArchive parses an archive containing Go files and their
// contents. The result is intended to be used with OverlayContext.
//
-//
-// Archive format
+// # Archive format
//
// The archive consists of a series of files. Each file consists of a
// name, a decimal file size and the file contents, separated by
diff --git a/go/buildutil/tags.go b/go/buildutil/tags.go
index 6da0ce4..7cf523b 100644
--- a/go/buildutil/tags.go
+++ b/go/buildutil/tags.go
@@ -20,7 +20,8 @@
// See $GOROOT/src/cmd/go/doc.go for description of 'go build -tags' flag.
//
// Example:
-// flag.Var((*buildutil.TagsFlag)(&build.Default.BuildTags), "tags", buildutil.TagsFlagDoc)
+//
+// flag.Var((*buildutil.TagsFlag)(&build.Default.BuildTags), "tags", buildutil.TagsFlagDoc)
type TagsFlag []string
func (v *TagsFlag) Set(s string) error {
diff --git a/go/buildutil/util.go b/go/buildutil/util.go
index fc923d7..d771b18 100644
--- a/go/buildutil/util.go
+++ b/go/buildutil/util.go
@@ -28,7 +28,6 @@
// filename that will be attached to the ASTs.
//
// TODO(adonovan): call this from go/loader.parseFiles when the tree thaws.
-//
func ParseFile(fset *token.FileSet, ctxt *build.Context, displayPath func(string) string, dir string, file string, mode parser.Mode) (*ast.File, error) {
if !IsAbsPath(ctxt, file) {
file = JoinPath(ctxt, dir, file)
@@ -51,7 +50,6 @@
//
// The '...Files []string' fields of the resulting build.Package are not
// populated (build.FindOnly mode).
-//
func ContainingPackage(ctxt *build.Context, dir, filename string) (*build.Package, error) {
if !IsAbsPath(ctxt, filename) {
filename = JoinPath(ctxt, dir, filename)
@@ -196,7 +194,6 @@
// sameFile returns true if x and y have the same basename and denote
// the same file.
-//
func sameFile(x, y string) bool {
if path.Clean(x) == path.Clean(y) {
return true
diff --git a/go/cfg/builder.go b/go/cfg/builder.go
index 7f95a29..dad6a44 100644
--- a/go/cfg/builder.go
+++ b/go/cfg/builder.go
@@ -443,7 +443,6 @@
// Destinations associated with unlabeled for/switch/select stmts.
// We push/pop one of these as we enter/leave each construct and for
// each BranchStmt we scan for the innermost target of the right type.
-//
type targets struct {
tail *targets // rest of stack
_break *Block
@@ -454,7 +453,6 @@
// Destinations associated with a labeled block.
// We populate these as labels are encountered in forward gotos or
// labeled statements.
-//
type lblock struct {
_goto *Block
_break *Block
@@ -463,7 +461,6 @@
// labeledBlock returns the branch target associated with the
// specified label, creating it if needed.
-//
func (b *builder) labeledBlock(label *ast.Ident) *lblock {
lb := b.lblocks[label.Obj]
if lb == nil {
diff --git a/go/cfg/cfg.go b/go/cfg/cfg.go
index 3ebc65f..37d799f 100644
--- a/go/cfg/cfg.go
+++ b/go/cfg/cfg.go
@@ -20,14 +20,14 @@
//
// produces this CFG:
//
-// 1: x := f()
-// x != nil
-// succs: 2, 3
-// 2: T()
-// succs: 4
-// 3: F()
-// succs: 4
-// 4:
+// 1: x := f()
+// x != nil
+// succs: 2, 3
+// 2: T()
+// succs: 4
+// 3: F()
+// succs: 4
+// 4:
//
// The CFG does contain Return statements; even implicit returns are
// materialized (at the position of the function's closing brace).
@@ -36,7 +36,6 @@
// edges, nor the short-circuit semantics of the && and || operators,
// nor abnormal control flow caused by panic. If you need this
// information, use golang.org/x/tools/go/ssa instead.
-//
package cfg
import (
diff --git a/go/expect/expect.go b/go/expect/expect.go
index bb203f5..f5172ce 100644
--- a/go/expect/expect.go
+++ b/go/expect/expect.go
@@ -16,20 +16,19 @@
For example, the test suite for a static checking tool might
use a @diag note to indicate an expected diagnostic:
- fmt.Printf("%s", 1) //@ diag("%s wants a string, got int")
+ fmt.Printf("%s", 1) //@ diag("%s wants a string, got int")
By contrast, the test suite for a source code navigation tool
might use notes to indicate the positions of features of
interest, the actions to be performed by the test,
and their expected outcomes:
- var x = 1 //@ x_decl
- ...
- print(x) //@ definition("x", x_decl)
- print(x) //@ typeof("x", "int")
+ var x = 1 //@ x_decl
+ ...
+ print(x) //@ definition("x", x_decl)
+ print(x) //@ typeof("x", "int")
-
-Note comment syntax
+# Note comment syntax
Note comments always start with the special marker @, which must be the
very first character after the comment opening pair, so //@ or /*@ with no
diff --git a/go/gccgoexportdata/gccgoexportdata_test.go b/go/gccgoexportdata/gccgoexportdata_test.go
index 0d04102..39f0981 100644
--- a/go/gccgoexportdata/gccgoexportdata_test.go
+++ b/go/gccgoexportdata/gccgoexportdata_test.go
@@ -18,12 +18,12 @@
//
// The testdata/{short,long}.a ELF archive files were produced by:
//
-// $ echo 'package foo; func F()' > foo.go
-// $ gccgo -c -fgo-pkgpath blah foo.go
-// $ objcopy -j .go_export foo.o foo.gox
-// $ ar q short.a foo.gox
-// $ objcopy -j .go_export foo.o name-longer-than-16-bytes.gox
-// $ ar q long.a name-longer-than-16-bytes.gox
+// $ echo 'package foo; func F()' > foo.go
+// $ gccgo -c -fgo-pkgpath blah foo.go
+// $ objcopy -j .go_export foo.o foo.gox
+// $ ar q short.a foo.gox
+// $ objcopy -j .go_export foo.o name-longer-than-16-bytes.gox
+// $ ar q long.a name-longer-than-16-bytes.gox
//
// The file long.a contains an archive string table.
//
diff --git a/go/gcexportdata/gcexportdata.go b/go/gcexportdata/gcexportdata.go
index cec819d6..d50826d 100644
--- a/go/gcexportdata/gcexportdata.go
+++ b/go/gcexportdata/gcexportdata.go
@@ -17,7 +17,6 @@
// developer tools, which will then be able to consume both Go 1.7 and
// Go 1.8 export data files, so they will work before and after the
// Go update. (See discussion at https://golang.org/issue/15651.)
-//
package gcexportdata // import "golang.org/x/tools/go/gcexportdata"
import (
diff --git a/go/gcexportdata/importer.go b/go/gcexportdata/importer.go
index efe221e..fe6ed93 100644
--- a/go/gcexportdata/importer.go
+++ b/go/gcexportdata/importer.go
@@ -22,7 +22,6 @@
// version-skew problems described in the documentation of this package,
// or to control the FileSet or access the imports map populated during
// package loading.
-//
func NewImporter(fset *token.FileSet, imports map[string]*types.Package) types.ImporterFrom {
return importer{fset, imports}
}
diff --git a/go/loader/doc.go b/go/loader/doc.go
index c5aa31c..e35b1fd 100644
--- a/go/loader/doc.go
+++ b/go/loader/doc.go
@@ -20,36 +20,35 @@
// be called any number of times. Finally, these are followed by a
// call to Load() to actually load and type-check the program.
//
-// var conf loader.Config
+// var conf loader.Config
//
-// // Use the command-line arguments to specify
-// // a set of initial packages to load from source.
-// // See FromArgsUsage for help.
-// rest, err := conf.FromArgs(os.Args[1:], wantTests)
+// // Use the command-line arguments to specify
+// // a set of initial packages to load from source.
+// // See FromArgsUsage for help.
+// rest, err := conf.FromArgs(os.Args[1:], wantTests)
//
-// // Parse the specified files and create an ad hoc package with path "foo".
-// // All files must have the same 'package' declaration.
-// conf.CreateFromFilenames("foo", "foo.go", "bar.go")
+// // Parse the specified files and create an ad hoc package with path "foo".
+// // All files must have the same 'package' declaration.
+// conf.CreateFromFilenames("foo", "foo.go", "bar.go")
//
-// // Create an ad hoc package with path "foo" from
-// // the specified already-parsed files.
-// // All ASTs must have the same 'package' declaration.
-// conf.CreateFromFiles("foo", parsedFiles)
+// // Create an ad hoc package with path "foo" from
+// // the specified already-parsed files.
+// // All ASTs must have the same 'package' declaration.
+// conf.CreateFromFiles("foo", parsedFiles)
//
-// // Add "runtime" to the set of packages to be loaded.
-// conf.Import("runtime")
+// // Add "runtime" to the set of packages to be loaded.
+// conf.Import("runtime")
//
-// // Adds "fmt" and "fmt_test" to the set of packages
-// // to be loaded. "fmt" will include *_test.go files.
-// conf.ImportWithTests("fmt")
+// // Adds "fmt" and "fmt_test" to the set of packages
+// // to be loaded. "fmt" will include *_test.go files.
+// conf.ImportWithTests("fmt")
//
-// // Finally, load all the packages specified by the configuration.
-// prog, err := conf.Load()
+// // Finally, load all the packages specified by the configuration.
+// prog, err := conf.Load()
//
// See examples_test.go for examples of API usage.
//
-//
-// CONCEPTS AND TERMINOLOGY
+// # CONCEPTS AND TERMINOLOGY
//
// The WORKSPACE is the set of packages accessible to the loader. The
// workspace is defined by Config.Build, a *build.Context. The
@@ -92,7 +91,6 @@
// The INITIAL packages are those specified in the configuration. A
// DEPENDENCY is a package loaded to satisfy an import in an initial
// package or another dependency.
-//
package loader
// IMPLEMENTATION NOTES
diff --git a/go/loader/loader.go b/go/loader/loader.go
index 3ba91f7..edf62c2 100644
--- a/go/loader/loader.go
+++ b/go/loader/loader.go
@@ -179,7 +179,6 @@
// for a single package.
//
// Not mutated once exposed via the API.
-//
type PackageInfo struct {
Pkg *types.Package
Importable bool // true if 'import "Pkg.Path()"' would resolve to this
@@ -217,7 +216,6 @@
// src specifies the parser input as a string, []byte, or io.Reader, and
// filename is its apparent name. If src is nil, the contents of
// filename are read from the file system.
-//
func (conf *Config) ParseFile(filename string, src interface{}) (*ast.File, error) {
// TODO(adonovan): use conf.build() etc like parseFiles does.
return parser.ParseFile(conf.fset(), filename, src, conf.ParserMode)
@@ -262,7 +260,6 @@
//
// Only superficial errors are reported at this stage; errors dependent
// on I/O are detected during Load.
-//
func (conf *Config) FromArgs(args []string, xtest bool) ([]string, error) {
var rest []string
for i, arg := range args {
@@ -300,14 +297,12 @@
// CreateFromFilenames is a convenience function that adds
// a conf.CreatePkgs entry to create a package of the specified *.go
// files.
-//
func (conf *Config) CreateFromFilenames(path string, filenames ...string) {
conf.CreatePkgs = append(conf.CreatePkgs, PkgSpec{Path: path, Filenames: filenames})
}
// CreateFromFiles is a convenience function that adds a conf.CreatePkgs
// entry to create package of the specified path and parsed files.
-//
func (conf *Config) CreateFromFiles(path string, files ...*ast.File) {
conf.CreatePkgs = append(conf.CreatePkgs, PkgSpec{Path: path, Files: files})
}
@@ -321,12 +316,10 @@
// In addition, if any *_test.go files contain a "package x_test"
// declaration, an additional package comprising just those files will
// be added to CreatePkgs.
-//
func (conf *Config) ImportWithTests(path string) { conf.addImport(path, true) }
// Import is a convenience function that adds path to ImportPkgs, the
// set of initial packages that will be imported from source.
-//
func (conf *Config) Import(path string) { conf.addImport(path, false) }
func (conf *Config) addImport(path string, tests bool) {
@@ -345,7 +338,6 @@
// exact is defined as for astutil.PathEnclosingInterval.
//
// The zero value is returned if not found.
-//
func (prog *Program) PathEnclosingInterval(start, end token.Pos) (pkg *PackageInfo, path []ast.Node, exact bool) {
for _, info := range prog.AllPackages {
for _, f := range info.Files {
@@ -368,7 +360,6 @@
// InitialPackages returns a new slice containing the set of initial
// packages (Created + Imported) in unspecified order.
-//
func (prog *Program) InitialPackages() []*PackageInfo {
infos := make([]*PackageInfo, 0, len(prog.Created)+len(prog.Imported))
infos = append(infos, prog.Created...)
@@ -435,7 +426,6 @@
// Upon completion, exactly one of info and err is non-nil:
// info on successful creation of a package, err otherwise.
// A successful package may still contain type errors.
-//
type importInfo struct {
path string // import path
info *PackageInfo // results of typechecking (including errors)
@@ -475,7 +465,6 @@
// false, Load will fail if any package had an error.
//
// It is an error if no packages were loaded.
-//
func (conf *Config) Load() (*Program, error) {
// Create a simple default error handler for parse/type errors.
if conf.TypeChecker.Error == nil {
@@ -732,10 +721,10 @@
// errors that were encountered.
//
// 'which' indicates which files to include:
-// 'g': include non-test *.go source files (GoFiles + processed CgoFiles)
-// 't': include in-package *_test.go source files (TestGoFiles)
-// 'x': include external *_test.go source files. (XTestGoFiles)
//
+// 'g': include non-test *.go source files (GoFiles + processed CgoFiles)
+// 't': include in-package *_test.go source files (TestGoFiles)
+// 'x': include external *_test.go source files. (XTestGoFiles)
func (conf *Config) parsePackageFiles(bp *build.Package, which rune) ([]*ast.File, []error) {
if bp.ImportPath == "unsafe" {
return nil, nil
@@ -776,7 +765,6 @@
// in the package's PackageInfo).
//
// Idempotent.
-//
func (imp *importer) doImport(from *PackageInfo, to string) (*types.Package, error) {
if to == "C" {
// This should be unreachable, but ad hoc packages are
@@ -868,7 +856,6 @@
//
// fromDir is the directory containing the import declaration that
// caused these imports.
-//
func (imp *importer) importAll(fromPath, fromDir string, imports map[string]bool, mode build.ImportMode) (infos []*PackageInfo, errors []importError) {
if fromPath != "" {
// We're loading a set of imports.
@@ -951,7 +938,6 @@
// caller must call awaitCompletion() before accessing its info field.
//
// startLoad is concurrency-safe and idempotent.
-//
func (imp *importer) startLoad(bp *build.Package) *importInfo {
path := bp.ImportPath
imp.importedMu.Lock()
@@ -995,7 +981,6 @@
//
// cycleCheck determines whether the imports within files create
// dependency edges that should be checked for potential cycles.
-//
func (imp *importer) addFiles(info *PackageInfo, files []*ast.File, cycleCheck bool) {
// Ensure the dependencies are loaded, in parallel.
var fromPath string
diff --git a/go/loader/util.go b/go/loader/util.go
index 7f38dd7..3a80aca 100644
--- a/go/loader/util.go
+++ b/go/loader/util.go
@@ -27,7 +27,6 @@
//
// I/O is done via ctxt, which may specify a virtual file system.
// displayPath is used to transform the filenames attached to the ASTs.
-//
func parseFiles(fset *token.FileSet, ctxt *build.Context, displayPath func(string) string, dir string, files []string, mode parser.Mode) ([]*ast.File, []error) {
if displayPath == nil {
displayPath = func(path string) string { return path }
diff --git a/go/packages/doc.go b/go/packages/doc.go
index 4bfe28a..da4ab89 100644
--- a/go/packages/doc.go
+++ b/go/packages/doc.go
@@ -67,7 +67,6 @@
uninterpreted to the loader, so that the loader can interpret them
according to the conventions of the underlying build system.
See the Example function for typical usage.
-
*/
package packages // import "golang.org/x/tools/go/packages"
diff --git a/go/packages/packages.go b/go/packages/packages.go
index 2442845..f9bc35d 100644
--- a/go/packages/packages.go
+++ b/go/packages/packages.go
@@ -1079,7 +1079,6 @@
//
// Because files are scanned in parallel, the token.Pos
// positions of the resulting ast.Files are not ordered.
-//
func (ld *loader) parseFiles(filenames []string) ([]*ast.File, []error) {
var wg sync.WaitGroup
n := len(filenames)
@@ -1123,7 +1122,6 @@
// sameFile returns true if x and y have the same basename and denote
// the same file.
-//
func sameFile(x, y string) bool {
if x == y {
// It could be the case that y doesn't exist.
diff --git a/go/packages/packagestest/expect.go b/go/packages/packagestest/expect.go
index c1781e7..3088d43 100644
--- a/go/packages/packagestest/expect.go
+++ b/go/packages/packagestest/expect.go
@@ -41,24 +41,27 @@
// call the Mark method to add the marker to the global set.
// You can register the "mark" method to override these in your own call to
// Expect. The bound Mark function is usable directly in your method map, so
-// exported.Expect(map[string]interface{}{"mark": exported.Mark})
+//
+// exported.Expect(map[string]interface{}{"mark": exported.Mark})
+//
// replicates the built in behavior.
//
-// Method invocation
+// # Method invocation
//
// When invoking a method the expressions in the parameter list need to be
// converted to values to be passed to the method.
// There are a very limited set of types the arguments are allowed to be.
-// expect.Note : passed the Note instance being evaluated.
-// string : can be supplied either a string literal or an identifier.
-// int : can only be supplied an integer literal.
-// *regexp.Regexp : can only be supplied a regular expression literal
-// token.Pos : has a file position calculated as described below.
-// token.Position : has a file position calculated as described below.
-// expect.Range: has a start and end position as described below.
-// interface{} : will be passed any value
//
-// Position calculation
+// expect.Note : passed the Note instance being evaluated.
+// string : can be supplied either a string literal or an identifier.
+// int : can only be supplied an integer literal.
+// *regexp.Regexp : can only be supplied a regular expression literal
+// token.Pos : has a file position calculated as described below.
+// token.Position : has a file position calculated as described below.
+// expect.Range: has a start and end position as described below.
+// interface{} : will be passed any value
+//
+// # Position calculation
//
// There is some extra handling when a parameter is being coerced into a
// token.Pos, token.Position or Range type argument.
diff --git a/go/packages/packagestest/export.go b/go/packages/packagestest/export.go
index d792c3c..996be03 100644
--- a/go/packages/packagestest/export.go
+++ b/go/packages/packagestest/export.go
@@ -9,7 +9,7 @@
systems from the same description, and run the same tests on them in many
cases.
-Example
+# Example
As an example of packagestest use, consider the following test that runs
the 'go list' command on the specified modules:
@@ -60,7 +60,6 @@
main_test.go:36: 'go list gopher.example/...' with Modules mode layout:
gopher.example/repoa/a
gopher.example/repob/b
-
*/
package packagestest
@@ -452,17 +451,19 @@
// GroupFilesByModules attempts to map directories to the modules within each directory.
// This function assumes that the folder is structured in the following way:
-// - dir
-// - primarymod
-// - .go files
-// - packages
-// - go.mod (optional)
-// - modules
-// - repoa
-// - mod1
-// - .go files
-// - packages
-// - go.mod (optional)
+//
+// dir/
+// primarymod/
+// *.go files
+// packages
+// go.mod (optional)
+// modules/
+// repoa/
+// mod1/
+// *.go files
+// packages
+// go.mod (optional)
+//
// It scans the directory tree anchored at root and adds a Copy writer to the
// map for every file found.
// This is to enable the common case in tests where you have a full copy of the
diff --git a/go/packages/packagestest/gopath.go b/go/packages/packagestest/gopath.go
index 5401685..d56f523 100644
--- a/go/packages/packagestest/gopath.go
+++ b/go/packages/packagestest/gopath.go
@@ -12,26 +12,33 @@
// GOPATH is the exporter that produces GOPATH layouts.
// Each "module" is put in it's own GOPATH entry to help test complex cases.
// Given the two files
-// golang.org/repoa#a/a.go
-// golang.org/repob#b/b.go
+//
+// golang.org/repoa#a/a.go
+// golang.org/repob#b/b.go
+//
// You would get the directory layout
-// /sometemporarydirectory
-// ├── repoa
-// │ └── src
-// │ └── golang.org
-// │ └── repoa
-// │ └── a
-// │ └── a.go
-// └── repob
-// └── src
-// └── golang.org
-// └── repob
-// └── b
-// └── b.go
+//
+// /sometemporarydirectory
+// ├── repoa
+// │ └── src
+// │ └── golang.org
+// │ └── repoa
+// │ └── a
+// │ └── a.go
+// └── repob
+// └── src
+// └── golang.org
+// └── repob
+// └── b
+// └── b.go
+//
// GOPATH would be set to
-// /sometemporarydirectory/repoa;/sometemporarydirectory/repob
+//
+// /sometemporarydirectory/repoa;/sometemporarydirectory/repob
+//
// and the working directory would be
-// /sometemporarydirectory/repoa/src
+//
+// /sometemporarydirectory/repoa/src
var GOPATH = gopath{}
func init() {
diff --git a/go/packages/packagestest/modules.go b/go/packages/packagestest/modules.go
index 2c43567..69a6c93 100644
--- a/go/packages/packagestest/modules.go
+++ b/go/packages/packagestest/modules.go
@@ -23,20 +23,25 @@
// Each "repository" is put in it's own module, and the module file generated
// will have replace directives for all other modules.
// Given the two files
-// golang.org/repoa#a/a.go
-// golang.org/repob#b/b.go
+//
+// golang.org/repoa#a/a.go
+// golang.org/repob#b/b.go
+//
// You would get the directory layout
-// /sometemporarydirectory
-// ├── repoa
-// │ ├── a
-// │ │ └── a.go
-// │ └── go.mod
-// └── repob
-// ├── b
-// │ └── b.go
-// └── go.mod
+//
+// /sometemporarydirectory
+// ├── repoa
+// │ ├── a
+// │ │ └── a.go
+// │ └── go.mod
+// └── repob
+// ├── b
+// │ └── b.go
+// └── go.mod
+//
// and the working directory would be
-// /sometemporarydirectory/repoa
+//
+// /sometemporarydirectory/repoa
var Modules = modules{}
type modules struct{}
diff --git a/go/types/objectpath/objectpath.go b/go/types/objectpath/objectpath.go
index 557202b..f27d871 100644
--- a/go/types/objectpath/objectpath.go
+++ b/go/types/objectpath/objectpath.go
@@ -14,8 +14,10 @@
// distinct but logically equivalent.
//
// A single object may have multiple paths. In this example,
-// type A struct{ X int }
-// type B A
+//
+// type A struct{ X int }
+// type B A
+//
// the field X has two paths due to its membership of both A and B.
// The For(obj) function always returns one of these paths, arbitrarily
// but consistently.
@@ -45,30 +47,30 @@
// The sequences represent a path through the package/object/type graph.
// We classify these operators by their type:
//
-// PO package->object Package.Scope.Lookup
-// OT object->type Object.Type
-// TT type->type Type.{Elem,Key,Params,Results,Underlying} [EKPRU]
-// TO type->object Type.{At,Field,Method,Obj} [AFMO]
+// PO package->object Package.Scope.Lookup
+// OT object->type Object.Type
+// TT type->type Type.{Elem,Key,Params,Results,Underlying} [EKPRU]
+// TO type->object Type.{At,Field,Method,Obj} [AFMO]
//
// All valid paths start with a package and end at an object
// and thus may be defined by the regular language:
//
-// objectpath = PO (OT TT* TO)*
+// objectpath = PO (OT TT* TO)*
//
// The concrete encoding follows directly:
-// - The only PO operator is Package.Scope.Lookup, which requires an identifier.
-// - The only OT operator is Object.Type,
-// which we encode as '.' because dot cannot appear in an identifier.
-// - The TT operators are encoded as [EKPRUTC];
-// one of these (TypeParam) requires an integer operand,
-// which is encoded as a string of decimal digits.
-// - The TO operators are encoded as [AFMO];
-// three of these (At,Field,Method) require an integer operand,
-// which is encoded as a string of decimal digits.
-// These indices are stable across different representations
-// of the same package, even source and export data.
-// The indices used are implementation specific and may not correspond to
-// the argument to the go/types function.
+// - The only PO operator is Package.Scope.Lookup, which requires an identifier.
+// - The only OT operator is Object.Type,
+// which we encode as '.' because dot cannot appear in an identifier.
+// - The TT operators are encoded as [EKPRUTC];
+// one of these (TypeParam) requires an integer operand,
+// which is encoded as a string of decimal digits.
+// - The TO operators are encoded as [AFMO];
+// three of these (At,Field,Method) require an integer operand,
+// which is encoded as a string of decimal digits.
+// These indices are stable across different representations
+// of the same package, even source and export data.
+// The indices used are implementation specific and may not correspond to
+// the argument to the go/types function.
//
// In the example below,
//
@@ -81,15 +83,14 @@
// field X has the path "T.UM0.RA1.F0",
// representing the following sequence of operations:
//
-// p.Lookup("T") T
-// .Type().Underlying().Method(0). f
-// .Type().Results().At(1) b
-// .Type().Field(0) X
+// p.Lookup("T") T
+// .Type().Underlying().Method(0). f
+// .Type().Results().At(1) b
+// .Type().Field(0) X
//
// The encoding is not maximally compact---every R or P is
// followed by an A, for example---but this simplifies the
// encoder and decoder.
-//
const (
// object->type operators
opType = '.' // .Type() (Object)
@@ -136,10 +137,10 @@
//
// For(X) would return a path that denotes the following sequence of operations:
//
-// p.Scope().Lookup("T") (TypeName T)
-// .Type().Underlying().Method(0). (method Func f)
-// .Type().Results().At(1) (field Var b)
-// .Type().Field(0) (field Var X)
+// p.Scope().Lookup("T") (TypeName T)
+// .Type().Underlying().Method(0). (method Func f)
+// .Type().Results().At(1) (field Var b)
+// .Type().Field(0) (field Var X)
//
// where p is the package (*types.Package) to which X belongs.
func For(obj types.Object) (Path, error) {
diff --git a/go/types/typeutil/imports.go b/go/types/typeutil/imports.go
index 9c441db..b81ce0c 100644
--- a/go/types/typeutil/imports.go
+++ b/go/types/typeutil/imports.go
@@ -12,7 +12,6 @@
// package Q, Q appears earlier than P in the result.
// The algorithm follows import statements in the order they
// appear in the source code, so the result is a total order.
-//
func Dependencies(pkgs ...*types.Package) []*types.Package {
var result []*types.Package
seen := make(map[*types.Package]bool)
diff --git a/go/types/typeutil/map.go b/go/types/typeutil/map.go
index c9f8f25..dcc029b 100644
--- a/go/types/typeutil/map.go
+++ b/go/types/typeutil/map.go
@@ -24,7 +24,6 @@
// Just as with map[K]V, a nil *Map is a valid empty map.
//
// Not thread-safe.
-//
type Map struct {
hasher Hasher // shared by many Maps
table map[uint32][]entry // maps hash to bucket; entry.key==nil means unused
@@ -57,14 +56,12 @@
//
// If SetHasher is not called, the Map will create a private hasher at
// the first call to Insert.
-//
func (m *Map) SetHasher(hasher Hasher) {
m.hasher = hasher
}
// Delete removes the entry with the given key, if any.
// It returns true if the entry was found.
-//
func (m *Map) Delete(key types.Type) bool {
if m != nil && m.table != nil {
hash := m.hasher.Hash(key)
@@ -84,7 +81,6 @@
// At returns the map entry for the given key.
// The result is nil if the entry is not present.
-//
func (m *Map) At(key types.Type) interface{} {
if m != nil && m.table != nil {
for _, e := range m.table[m.hasher.Hash(key)] {
@@ -145,7 +141,6 @@
// f will not be invoked for it, but if f inserts a map entry that
// Iterate has not yet reached, whether or not f will be invoked for
// it is unspecified.
-//
func (m *Map) Iterate(f func(key types.Type, value interface{})) {
if m != nil {
for _, bucket := range m.table {
@@ -190,14 +185,12 @@
// String returns a string representation of the map's entries.
// Values are printed using fmt.Sprintf("%v", v).
// Order is unspecified.
-//
func (m *Map) String() string {
return m.toString(true)
}
// KeysString returns a string representation of the map's key set.
// Order is unspecified.
-//
func (m *Map) KeysString() string {
return m.toString(false)
}
diff --git a/go/types/typeutil/methodsetcache.go b/go/types/typeutil/methodsetcache.go
index 3208461..a5d9310 100644
--- a/go/types/typeutil/methodsetcache.go
+++ b/go/types/typeutil/methodsetcache.go
@@ -25,7 +25,6 @@
// If cache is nil, this function is equivalent to types.NewMethodSet(T).
// Utility functions can thus expose an optional *MethodSetCache
// parameter to clients that care about performance.
-//
func (cache *MethodSetCache) MethodSet(T types.Type) *types.MethodSet {
if cache == nil {
return types.NewMethodSet(T)
diff --git a/go/types/typeutil/ui.go b/go/types/typeutil/ui.go
index 9849c24..fa55b0a 100644
--- a/go/types/typeutil/ui.go
+++ b/go/types/typeutil/ui.go
@@ -22,7 +22,6 @@
// this function is intended only for user interfaces.
//
// The order of the result is as for types.MethodSet(T).
-//
func IntuitiveMethodSet(T types.Type, msets *MethodSetCache) []*types.Selection {
isPointerToConcrete := func(T types.Type) bool {
ptr, ok := T.(*types.Pointer)
diff --git a/go/vcs/vcs.go b/go/vcs/vcs.go
index f2aac1c..54d8505 100644
--- a/go/vcs/vcs.go
+++ b/go/vcs/vcs.go
@@ -11,7 +11,6 @@
// for developers who want to write tools with similar semantics.
// It needs to be manually kept in sync with upstream when changes are
// made to cmd/go/internal/get; see https://golang.org/issue/11490.
-//
package vcs // import "golang.org/x/tools/go/vcs"
import (
diff --git a/godoc/analysis/analysis.go b/godoc/analysis/analysis.go
index de8e470..54611e8 100644
--- a/godoc/analysis/analysis.go
+++ b/godoc/analysis/analysis.go
@@ -39,7 +39,6 @@
// ERRORS: for each locus of a frontend (scanner/parser/type) error, the
// location is highlighted in red and hover text provides the compiler
// error message.
-//
package analysis // import "golang.org/x/tools/godoc/analysis"
import (
@@ -160,7 +159,6 @@
// HTML link markup for the specified godoc file URL. Thread-safe.
// Callers must not mutate the elements.
// It returns "zero" if no data is available.
-//
func (res *Result) FileInfo(url string) (fi FileInfo) {
return res.fileInfo(url).get()
}
@@ -185,7 +183,6 @@
// type info for the specified package. Thread-safe.
// Callers must not mutate its fields.
// PackageInfo returns "zero" if no data is available.
-//
func (res *Result) PackageInfo(importPath string) PackageInfo {
return res.pkgInfo(importPath).get()
}
diff --git a/godoc/dirtrees.go b/godoc/dirtrees.go
index 82c9a06..f6a5ba0 100644
--- a/godoc/dirtrees.go
+++ b/godoc/dirtrees.go
@@ -22,7 +22,6 @@
// Conventional name for directories containing test data.
// Excluded from directory trees.
-//
const testdataDirName = "testdata"
type Directory struct {
@@ -217,7 +216,6 @@
// provided for maxDepth, nodes at larger depths are pruned as well; they
// are assumed to contain package files even if their contents are not known
// (i.e., in this case the tree may contain directories w/o any package files).
-//
func (c *Corpus) newDirectory(root string, maxDepth int) *Directory {
// The root could be a symbolic link so use Stat not Lstat.
d, err := c.fs.Stat(root)
@@ -300,7 +298,6 @@
// DirEntry describes a directory entry. The Depth and Height values
// are useful for presenting an entry in an indented fashion.
-//
type DirEntry struct {
Depth int // >= 0
Height int // = DirList.MaxHeight - Depth, > 0
@@ -331,7 +328,6 @@
// If skipRoot is set, the root directory itself is excluded from the list.
// If filter is set, only the directory entries whose paths match the filter
// are included.
-//
func (dir *Directory) listing(skipRoot bool, filter func(string) bool) *DirList {
if dir == nil {
return nil
diff --git a/godoc/format.go b/godoc/format.go
index 3e8c867..eaac8bf 100644
--- a/godoc/format.go
+++ b/godoc/format.go
@@ -25,7 +25,6 @@
// A Segment describes a text segment [start, end).
// The zero value of a Segment is a ready-to-use empty segment.
-//
type Segment struct {
start, end int
}
@@ -36,12 +35,10 @@
// Repeated calls to a selection return consecutive, non-overlapping,
// non-empty segments, followed by an infinite sequence of empty
// segments. The first empty segment marks the end of the selection.
-//
type Selection func() Segment
// A LinkWriter writes some start or end "tag" to w for the text offset offs.
// It is called by FormatSelections at the start or end of each link segment.
-//
type LinkWriter func(w io.Writer, offs int, start bool)
// A SegmentWriter formats a text according to selections and writes it to w.
@@ -49,7 +46,6 @@
// to FormatSelections overlap with the text segment: If the n'th bit is set
// in selections, the n'th selection provided to FormatSelections is overlapping
// with the text.
-//
type SegmentWriter func(w io.Writer, text []byte, selections int)
// FormatSelections takes a text and writes it to w using link and segment
@@ -58,7 +54,6 @@
// consecutive segments of text overlapped by the same selections as specified
// by selections. The link writer lw may be nil, in which case the links
// Selection is ignored.
-//
func FormatSelections(w io.Writer, text []byte, lw LinkWriter, links Selection, sw SegmentWriter, selections ...Selection) {
// If we have a link writer, make the links
// selection the last entry in selections
@@ -144,7 +139,6 @@
// A merger merges a slice of Selections and produces a sequence of
// consecutive segment change events through repeated next() calls.
-//
type merger struct {
selections []Selection
segments []Segment // segments[i] is the next segment of selections[i]
@@ -169,7 +163,6 @@
// to which the segment belongs, offs is the segment start or end offset
// as determined by the start value. If there are no more segment changes,
// next returns an index value < 0.
-//
func (m *merger) next() (index, offs int, start bool) {
// find the next smallest offset where a segment starts or ends
offs = infinity
@@ -233,7 +226,6 @@
// tokenSelection returns, as a selection, the sequence of
// consecutive occurrences of token sel in the Go src text.
-//
func tokenSelection(src []byte, sel token.Token) Selection {
var s scanner.Scanner
fset := token.NewFileSet()
@@ -257,7 +249,6 @@
// makeSelection is a helper function to make a Selection from a slice of pairs.
// Pairs describing empty segments are ignored.
-//
func makeSelection(matches [][]int) Selection {
i := 0
return func() Segment {
@@ -306,7 +297,6 @@
// bit 0: comments
// bit 1: highlights
// bit 2: selections
-//
var startTags = [][]byte{
/* 000 */ []byte(``),
/* 001 */ []byte(`<span class="comment">`),
@@ -336,16 +326,15 @@
// Consecutive text segments are wrapped in HTML spans (with tags as
// defined by startTags and endTag) as follows:
//
-// - if line >= 0, line number (ln) spans are inserted before each line,
-// starting with the value of line
-// - if the text is Go source, comments get the "comment" span class
-// - each occurrence of the regular expression pattern gets the "highlight"
-// span class
-// - text segments covered by selection get the "selection" span class
+// - if line >= 0, line number (ln) spans are inserted before each line,
+// starting with the value of line
+// - if the text is Go source, comments get the "comment" span class
+// - each occurrence of the regular expression pattern gets the "highlight"
+// span class
+// - text segments covered by selection get the "selection" span class
//
// Comments, highlights, and selections may overlap arbitrarily; the respective
// HTML span classes are specified in the startTags variable.
-//
func FormatText(w io.Writer, text []byte, line int, goSource bool, pattern string, selection Selection) {
var comments, highlights Selection
if goSource {
diff --git a/godoc/godoc.go b/godoc/godoc.go
index a88aa12..7ff2eab 100644
--- a/godoc/godoc.go
+++ b/godoc/godoc.go
@@ -41,8 +41,8 @@
// FuncMap defines template functions used in godoc templates.
//
// Convention: template function names ending in "_html" or "_url" produce
-// HTML- or URL-escaped strings; all other function results may
-// require explicit escaping in the template.
+// HTML- or URL-escaped strings; all other function results may
+// require explicit escaping in the template.
func (p *Presentation) FuncMap() template.FuncMap {
p.initFuncMapOnce.Do(p.initFuncMap)
return p.funcMap
diff --git a/godoc/index.go b/godoc/index.go
index f6de201..d3f9f64 100644
--- a/godoc/index.go
+++ b/godoc/index.go
@@ -1359,7 +1359,6 @@
// LookupRegexp returns the number of matches and the matches where a regular
// expression r is found in the full text index. At most n matches are
// returned (thus found <= n).
-//
func (x *Index) LookupRegexp(r *regexp.Regexp, n int) (found int, result []FileLines) {
if x.suffixes == nil || n <= 0 {
return
@@ -1431,7 +1430,6 @@
// feedDirnames feeds the directory names of all directories
// under the file system given by root to channel c.
-//
func (c *Corpus) feedDirnames(ch chan<- string) {
if dir, _ := c.fsTree.Get(); dir != nil {
for d := range dir.(*Directory).iter(false) {
@@ -1442,7 +1440,6 @@
// fsDirnames() returns a channel sending all directory names
// of all the file systems under godoc's observation.
-//
func (c *Corpus) fsDirnames() <-chan string {
ch := make(chan string, 256) // buffered for fewer context switches
go func() {
diff --git a/godoc/linkify.go b/godoc/linkify.go
index 4a9c506..cf266d0 100644
--- a/godoc/linkify.go
+++ b/godoc/linkify.go
@@ -26,7 +26,6 @@
// not being declared), are wrapped with HTML links pointing
// to the respective declaration, if possible. Comments are
// formatted the same way as with FormatText.
-//
func LinkifyText(w io.Writer, text []byte, n ast.Node) {
links := linksFor(n)
@@ -75,7 +74,6 @@
// A link describes the (HTML) link information for an identifier.
// The zero value of a link represents "no link".
-//
type link struct {
path, name string // package path, identifier name
isVal bool // identifier is defined in a const or var declaration
@@ -83,7 +81,6 @@
// linksFor returns the list of links for the identifiers used
// by node in the same order as they appear in the source.
-//
func linksFor(node ast.Node) (links []link) {
// linkMap tracks link information for each ast.Ident node. Entries may
// be created out of source order (for example, when we visit a parent
diff --git a/godoc/meta.go b/godoc/meta.go
index 8d3b825..751b72e 100644
--- a/godoc/meta.go
+++ b/godoc/meta.go
@@ -43,7 +43,6 @@
// extractMetadata extracts the Metadata from a byte slice.
// It returns the Metadata value and the remaining data.
// If no metadata is present the original byte slice is returned.
-//
func extractMetadata(b []byte) (meta Metadata, tail []byte, err error) {
tail = b
if !bytes.HasPrefix(b, jsonStart) {
@@ -121,7 +120,6 @@
// MetadataFor returns the *Metadata for a given relative path or nil if none
// exists.
-//
func (c *Corpus) MetadataFor(relpath string) *Metadata {
if m, _ := c.docMetadata.Get(); m != nil {
meta := m.(map[string]*Metadata)
@@ -142,7 +140,6 @@
// refreshMetadata sends a signal to update DocMetadata. If a refresh is in
// progress the metadata will be refreshed again afterward.
-//
func (c *Corpus) refreshMetadata() {
select {
case c.refreshMetadataSignal <- true:
diff --git a/godoc/server.go b/godoc/server.go
index 9c5d556..57576e1 100644
--- a/godoc/server.go
+++ b/godoc/server.go
@@ -55,7 +55,6 @@
// directory, PageInfo.PAst and PageInfo.PDoc are nil. If there are no sub-
// directories, PageInfo.Dirs is nil. If an error occurred, PageInfo.Err is
// set to the respective error but the error is not logged.
-//
func (h *handlerServer) GetPageInfo(abspath, relpath string, mode PageInfoMode, goos, goarch string) *PageInfo {
info := &PageInfo{Dirname: abspath, Mode: mode}
@@ -411,7 +410,6 @@
// (as is the convention for packages). This is sufficient
// to resolve package identifiers without doing an actual
// import. It never returns an error.
-//
func poorMansImporter(imports map[string]*ast.Object, path string) (*ast.Object, error) {
pkg := imports[path]
if pkg == nil {
@@ -498,7 +496,6 @@
// which correctly updates each package file's comment list.
// (The ast.PackageExports signature is frozen, hence the local
// implementation).
-//
func packageExports(fset *token.FileSet, pkg *ast.Package) {
for _, src := range pkg.Files {
cmap := ast.NewCommentMap(fset, src, src.Comments)
@@ -621,7 +618,6 @@
// formatGoSource HTML-escapes Go source text and writes it to w,
// decorating it with the specified analysis links.
-//
func formatGoSource(buf *bytes.Buffer, text []byte, links []analysis.Link, pattern string, selection Selection) {
// Emit to a temp buffer so that we can add line anchors at the end.
saved, buf := buf, new(bytes.Buffer)
diff --git a/godoc/spot.go b/godoc/spot.go
index 95ffa4b..4720e5b 100644
--- a/godoc/spot.go
+++ b/godoc/spot.go
@@ -13,9 +13,8 @@
//
// The following encoding is used:
//
-// bits 32 4 1 0
-// value [lori|kind|isIndex]
-//
+// bits 32 4 1 0
+// value [lori|kind|isIndex]
type SpotInfo uint32
// SpotKind describes whether an identifier is declared (and what kind of
diff --git a/godoc/util/throttle.go b/godoc/util/throttle.go
index 53d9ba6..7852a32 100644
--- a/godoc/util/throttle.go
+++ b/godoc/util/throttle.go
@@ -8,7 +8,6 @@
// A Throttle permits throttling of a goroutine by
// calling the Throttle method repeatedly.
-//
type Throttle struct {
f float64 // f = (1-r)/r for 0 < r < 1
dt time.Duration // minimum run time slice; >= 0
@@ -27,7 +26,6 @@
// approx. 60% of the time, and sleeps approx. 40% of the time.
// Values of r < 0 or r > 1 are clamped down to values between 0 and 1.
// Values of dt < 0 are set to 0.
-//
func NewThrottle(r float64, dt time.Duration) *Throttle {
var f float64
switch {
@@ -49,7 +47,6 @@
// accumulated run (tr) and sleep times (ts) approximates the value 1/(1-r)
// where r is the throttle value. Throttle returns immediately (w/o sleeping)
// if less than tm ns have passed since the last call to Throttle.
-//
func (p *Throttle) Throttle() {
if p.f < 0 {
select {} // always sleep
diff --git a/godoc/vfs/namespace.go b/godoc/vfs/namespace.go
index 32c8259..23dd979 100644
--- a/godoc/vfs/namespace.go
+++ b/godoc/vfs/namespace.go
@@ -97,7 +97,6 @@
// mount table entries always have old == "/src/pkg"). The 'old' field is
// useful to callers, because they receive just a []mountedFS and not any
// other indication of which mount point was found.
-//
type NameSpace map[string][]mountedFS
// A mountedFS handles requests for path by replacing
@@ -294,7 +293,6 @@
// to find that subdirectory, because we've mounted d:\Work1 and d:\Work2
// there. So if we don't see "src" in the directory listing for c:\Go, we add an
// entry for it before returning.
-//
func (ns NameSpace) ReadDir(path string) ([]os.FileInfo, error) {
path = ns.clean(path)
diff --git a/godoc/vfs/zipfs/zipfs.go b/godoc/vfs/zipfs/zipfs.go
index a82febe..14c9820 100644
--- a/godoc/vfs/zipfs/zipfs.go
+++ b/godoc/vfs/zipfs/zipfs.go
@@ -7,14 +7,14 @@
//
// Assumptions:
//
-// - The file paths stored in the zip file must use a slash ('/') as path
-// separator; and they must be relative (i.e., they must not start with
-// a '/' - this is usually the case if the file was created w/o special
-// options).
-// - The zip file system treats the file paths found in the zip internally
-// like absolute paths w/o a leading '/'; i.e., the paths are considered
-// relative to the root of the file system.
-// - All path arguments to file system methods must be absolute paths.
+// - The file paths stored in the zip file must use a slash ('/') as path
+// separator; and they must be relative (i.e., they must not start with
+// a '/' - this is usually the case if the file was created w/o special
+// options).
+// - The zip file system treats the file paths found in the zip internally
+// like absolute paths w/o a leading '/'; i.e., the paths are considered
+// relative to the root of the file system.
+// - All path arguments to file system methods must be absolute paths.
package zipfs // import "golang.org/x/tools/godoc/vfs/zipfs"
import (
diff --git a/imports/forward.go b/imports/forward.go
index 8be18a6..d2547c7 100644
--- a/imports/forward.go
+++ b/imports/forward.go
@@ -40,7 +40,7 @@
//
// Note that filename's directory influences which imports can be chosen,
// so it is important that filename be accurate.
-// To process data ``as if'' it were in filename, pass the data as a non-nil src.
+// To process data “as if” it were in filename, pass the data as a non-nil src.
func Process(filename string, src []byte, opt *Options) ([]byte, error) {
var err error
if src == nil {
diff --git a/internal/apidiff/compatibility.go b/internal/apidiff/compatibility.go
index 6b5ba75..2e32748 100644
--- a/internal/apidiff/compatibility.go
+++ b/internal/apidiff/compatibility.go
@@ -138,13 +138,13 @@
}
// 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
diff --git a/internal/event/export/ocagent/wire/metrics.go b/internal/event/export/ocagent/wire/metrics.go
index 4cfdb88..6cb5894 100644
--- a/internal/event/export/ocagent/wire/metrics.go
+++ b/internal/event/export/ocagent/wire/metrics.go
@@ -71,9 +71,12 @@
// OpenCensus service can correctly determine the underlying value type.
// This custom MarshalJSON exists because,
// by default *Point is JSON marshalled as:
-// {"value": {"int64Value": 1}}
+//
+// {"value": {"int64Value": 1}}
+//
// but it should be marshalled as:
-// {"int64Value": 1}
+//
+// {"int64Value": 1}
func (p *Point) MarshalJSON() ([]byte, error) {
if p == nil {
return []byte("null"), nil
@@ -158,9 +161,12 @@
// OpenCensus service can correctly determine the underlying value type.
// This custom MarshalJSON exists because,
// by default BucketOptionsExplicit is JSON marshalled as:
-// {"bounds":[1,2,3]}
+//
+// {"bounds":[1,2,3]}
+//
// but it should be marshalled as:
-// {"explicit":{"bounds":[1,2,3]}}
+//
+// {"explicit":{"bounds":[1,2,3]}}
func (be *BucketOptionsExplicit) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Explicit *bucketOptionsExplicitAlias `json:"explicit,omitempty"`
diff --git a/internal/fastwalk/fastwalk.go b/internal/fastwalk/fastwalk.go
index 9887f7e..798fe59 100644
--- a/internal/fastwalk/fastwalk.go
+++ b/internal/fastwalk/fastwalk.go
@@ -40,12 +40,12 @@
// If fastWalk returns filepath.SkipDir, the directory is skipped.
//
// Unlike filepath.Walk:
-// * file stat calls must be done by the user.
+// - file stat calls must be done by the user.
// The only provided metadata is the file type, which does not include
// any permission bits.
-// * multiple goroutines stat the filesystem concurrently. The provided
+// - multiple goroutines stat the filesystem concurrently. The provided
// walkFn must be safe for concurrent use.
-// * fastWalk can follow symlinks if walkFn returns the TraverseLink
+// - fastWalk can follow symlinks if walkFn returns the TraverseLink
// sentinel error. It is the walkFn's responsibility to prevent
// fastWalk from going into symlink cycles.
func Walk(root string, walkFn func(path string, typ os.FileMode) error) error {
diff --git a/internal/imports/imports.go b/internal/imports/imports.go
index 2597398..7902672 100644
--- a/internal/imports/imports.go
+++ b/internal/imports/imports.go
@@ -276,11 +276,11 @@
}
// matchSpace reformats src to use the same space context as orig.
-// 1) If orig begins with blank lines, matchSpace inserts them at the beginning of src.
-// 2) matchSpace copies the indentation of the first non-blank line in orig
-// to every non-blank line in src.
-// 3) matchSpace copies the trailing space from orig and uses it in place
-// of src's trailing space.
+// 1. If orig begins with blank lines, matchSpace inserts them at the beginning of src.
+// 2. matchSpace copies the indentation of the first non-blank line in orig
+// to every non-blank line in src.
+// 3. matchSpace copies the trailing space from orig and uses it in place
+// of src's trailing space.
func matchSpace(orig []byte, src []byte) []byte {
before, _, after := cutSpace(orig)
i := bytes.LastIndex(before, []byte{'\n'})
diff --git a/internal/memoize/memoize.go b/internal/memoize/memoize.go
index 0037342..b3f93b6 100644
--- a/internal/memoize/memoize.go
+++ b/internal/memoize/memoize.go
@@ -7,7 +7,6 @@
//
// To use this package, build a store and use it to acquire handles with the
// Bind method.
-//
package memoize
import (
diff --git a/internal/stack/process.go b/internal/stack/process.go
index ac19366..8812de9 100644
--- a/internal/stack/process.go
+++ b/internal/stack/process.go
@@ -96,7 +96,7 @@
s.Calls[index].merge(gr)
}
-//TODO: do we want other grouping strategies?
+// TODO: do we want other grouping strategies?
func (c *Call) merge(gr Goroutine) {
for i := range c.Groups {
canditate := &c.Groups[i]
diff --git a/internal/stack/stacktest/stacktest.go b/internal/stack/stacktest/stacktest.go
index e23f03e..d778d3c 100644
--- a/internal/stack/stacktest/stacktest.go
+++ b/internal/stack/stacktest/stacktest.go
@@ -11,7 +11,7 @@
"golang.org/x/tools/internal/stack"
)
-//this is only needed to support pre 1.14 when testing.TB did not have Cleanup
+// this is only needed to support pre 1.14 when testing.TB did not have Cleanup
type withCleanup interface {
Cleanup(func())
}
diff --git a/internal/testenv/testenv.go b/internal/testenv/testenv.go
index b381232..d3f4776 100644
--- a/internal/testenv/testenv.go
+++ b/internal/testenv/testenv.go
@@ -222,7 +222,7 @@
NeedsGoPackages(t)
}
-// NeedsGoBuild skips t if the current system can't build programs with ``go build''
+// NeedsGoBuild skips t if the current system can't build programs with “go build”
// and then run them with os.StartProcess or exec.Command.
// android, and darwin/arm systems don't have the userspace go build needs to run,
// and js/wasm doesn't support running subprocesses.
diff --git a/internal/typeparams/common.go b/internal/typeparams/common.go
index ab6b30b..f7678d3 100644
--- a/internal/typeparams/common.go
+++ b/internal/typeparams/common.go
@@ -121,15 +121,15 @@
//
// For example, consider the following type declarations:
//
-// type Interface[T any] interface {
-// Accept(T)
-// }
+// type Interface[T any] interface {
+// Accept(T)
+// }
//
-// type Container[T any] struct {
-// Element T
-// }
+// type Container[T any] struct {
+// Element T
+// }
//
-// func (c Container[T]) Accept(t T) { c.Element = t }
+// func (c Container[T]) Accept(t T) { c.Element = t }
//
// In this case, GenericAssignableTo reports that instantiations of Container
// are assignable to the corresponding instantiation of Interface.
diff --git a/internal/typeparams/example/findtypeparams/main.go b/internal/typeparams/example/findtypeparams/main.go
index 0fe8011..b3f10c0 100644
--- a/internal/typeparams/example/findtypeparams/main.go
+++ b/internal/typeparams/example/findtypeparams/main.go
@@ -36,7 +36,7 @@
//!-input
`
-//!+print
+// !+print
func PrintTypeParams(fset *token.FileSet, file *ast.File) error {
conf := types.Config{Importer: importer.Default()}
info := &types.Info{
diff --git a/internal/typeparams/normalize.go b/internal/typeparams/normalize.go
index 090f142..9c631b6 100644
--- a/internal/typeparams/normalize.go
+++ b/internal/typeparams/normalize.go
@@ -24,20 +24,22 @@
// Structural type restrictions of a type parameter are created via
// non-interface types embedded in its constraint interface (directly, or via a
// chain of interface embeddings). For example, in the declaration
-// type T[P interface{~int; m()}] int
+//
+// type T[P interface{~int; m()}] int
+//
// the structural restriction of the type parameter P is ~int.
//
// With interface embedding and unions, the specification of structural type
// restrictions may be arbitrarily complex. For example, consider the
// following:
//
-// type A interface{ ~string|~[]byte }
+// type A interface{ ~string|~[]byte }
//
-// type B interface{ int|string }
+// type B interface{ int|string }
//
-// type C interface { ~string|~int }
+// type C interface { ~string|~int }
//
-// type T[P interface{ A|B; C }] int
+// type T[P interface{ A|B; C }] int
//
// In this example, the structural type restriction of P is ~string|int: A|B
// expands to ~string|~[]byte|int|string, which reduces to ~string|~[]byte|int,
diff --git a/internal/typeparams/typeterm.go b/internal/typeparams/typeterm.go
index 7ddee28..7350bb7 100644
--- a/internal/typeparams/typeterm.go
+++ b/internal/typeparams/typeterm.go
@@ -10,11 +10,10 @@
// A term describes elementary type sets:
//
-// ∅: (*term)(nil) == ∅ // set of no types (empty set)
-// 𝓤: &term{} == 𝓤 // set of all types (𝓤niverse)
-// T: &term{false, T} == {T} // set of type T
-// ~t: &term{true, t} == {t' | under(t') == t} // set of types with underlying type t
-//
+// ∅: (*term)(nil) == ∅ // set of no types (empty set)
+// 𝓤: &term{} == 𝓤 // set of all types (𝓤niverse)
+// T: &term{false, T} == {T} // set of type T
+// ~t: &term{true, t} == {t' | under(t') == t} // set of types with underlying type t
type term struct {
tilde bool // valid if typ != nil
typ types.Type
diff --git a/present/code.go b/present/code.go
index eb91555..f00f1f4 100644
--- a/present/code.go
+++ b/present/code.go
@@ -56,7 +56,9 @@
)
// parseCode parses a code present directive. Its syntax:
-// .code [-numbers] [-edit] <filename> [address] [highlight]
+//
+// .code [-numbers] [-edit] <filename> [address] [highlight]
+//
// The directive may also be ".play" if the snippet is executable.
func parseCode(ctx *Context, sourceFile string, sourceLine int, cmd string) (Elem, error) {
cmd = strings.TrimSpace(cmd)
diff --git a/present/doc.go b/present/doc.go
index b1e3fc4..71f758f 100644
--- a/present/doc.go
+++ b/present/doc.go
@@ -7,7 +7,7 @@
which can be slide presentations as in golang.org/x/tools/cmd/present
or articles as in golang.org/x/blog (the Go blog).
-File Format
+# File Format
Present files begin with a header giving the title of the document
and other metadata, which looks like:
@@ -26,7 +26,9 @@
legacy present markup, described below.
The date line may be written without a time:
+
2 Jan 2006
+
In this case, the time will be interpreted as 10am UTC on that date.
The tags line is a comma-separated list of tags that may be used to categorize
@@ -82,7 +84,7 @@
Other than the commands, the text in a section is interpreted
either as Markdown or as legacy present markup.
-Markdown Syntax
+# Markdown Syntax
Markdown typically means the generic name for a family of similar markup languages.
The specific variant used in present is CommonMark.
@@ -138,7 +140,7 @@
Visit [the Go home page](https://golang.org/).
-Legacy Present Syntax
+# Legacy Present Syntax
Compared to Markdown,
in legacy present
@@ -201,7 +203,7 @@
Links can be included in any text with the form [[url][label]], or
[[url]] to use the URL itself as the label.
-Command Invocations
+# Command Invocations
A number of special commands are available through invocations
in the input text. Each such invocation contains a period as the
@@ -224,38 +226,55 @@
section of the file to display. The address syntax is similar in
its simplest form to that of ed, but comes from sam and is more
general. See
+
https://plan9.io/sys/doc/sam/sam.html Table II
+
for full details. The displayed block is always rounded out to a
full line at both ends.
If no pattern is present, the entire file is displayed.
Any line in the program that ends with the four characters
+
OMIT
+
is deleted from the source before inclusion, making it easy
to write things like
+
.code test.go /START OMIT/,/END OMIT/
+
to find snippets like this
+
tedious_code = boring_function()
// START OMIT
interesting_code = fascinating_function()
// END OMIT
+
and see only this:
+
interesting_code = fascinating_function()
Also, inside the displayed text a line that ends
+
// HL
+
will be highlighted in the display. A highlighting mark may have a
suffix word, such as
+
// HLxxx
+
Such highlights are enabled only if the code invocation ends with
"HL" followed by the word:
+
.code test.go /^type Foo/,/^}/ HLxxx
The .code function may take one or more flags immediately preceding
the filename. This command shows test.go in an editable text area:
+
.code -edit test.go
+
This command shows test.go with line numbers:
+
.code -numbers test.go
play:
@@ -333,7 +352,7 @@
.html file.html
-Presenter Notes
+# Presenter Notes
Lines that begin with ": " are treated as presenter notes,
in both Markdown and legacy present syntax.
@@ -347,7 +366,7 @@
Notes may appear anywhere within the slide text. For example:
- * Title of slide
+ ## Title of slide
Some text.
@@ -356,6 +375,5 @@
Some more text.
: Presenter notes (subsequent paragraph(s))
-
*/
package present // import "golang.org/x/tools/present"
diff --git a/refactor/eg/eg.go b/refactor/eg/eg.go
index 0cd1937..15dfbd6 100644
--- a/refactor/eg/eg.go
+++ b/refactor/eg/eg.go
@@ -157,7 +157,6 @@
// a single-file package containing "before" and "after" functions as
// described in the package documentation.
// tmplInfo is the type information for tmplFile.
-//
func NewTransformer(fset *token.FileSet, tmplPkg *types.Package, tmplFile *ast.File, tmplInfo *types.Info, verbose bool) (*Transformer, error) {
// Check the template.
beforeSig := funcSig(tmplPkg, "before")
diff --git a/refactor/eg/match.go b/refactor/eg/match.go
index 89c0f8d..31f8af2 100644
--- a/refactor/eg/match.go
+++ b/refactor/eg/match.go
@@ -27,7 +27,6 @@
//
// A wildcard appearing more than once in the pattern must
// consistently match the same tree.
-//
func (tr *Transformer) matchExpr(x, y ast.Expr) bool {
if x == nil && y == nil {
return true
diff --git a/refactor/eg/rewrite.go b/refactor/eg/rewrite.go
index 1c3ee61..3f71c53 100644
--- a/refactor/eg/rewrite.go
+++ b/refactor/eg/rewrite.go
@@ -77,7 +77,6 @@
// available in info.
//
// Derived from rewriteFile in $GOROOT/src/cmd/gofmt/rewrite.go.
-//
func (tr *Transformer) Transform(info *types.Info, pkg *types.Package, file *ast.File) int {
if !tr.seenInfos[info] {
tr.seenInfos[info] = true
diff --git a/refactor/rename/check.go b/refactor/rename/check.go
index 838fc7b..7a0627b 100644
--- a/refactor/rename/check.go
+++ b/refactor/rename/check.go
@@ -206,7 +206,6 @@
//
// Removing the old name (and all references to it) is always safe, and
// requires no checks.
-//
func (r *renamer) checkInLexicalScope(from types.Object, info *loader.PackageInfo) {
b := from.Parent() // the block defining the 'from' object
if b != nil {
@@ -568,13 +567,14 @@
// checkMethod performs safety checks for renaming a method.
// There are three hazards:
-// - declaration conflicts
-// - selection ambiguity/changes
-// - entailed renamings of assignable concrete/interface types.
-// We reject renamings initiated at concrete methods if it would
-// change the assignability relation. For renamings of abstract
-// methods, we rename all methods transitively coupled to it via
-// assignability.
+// - declaration conflicts
+// - selection ambiguity/changes
+// - entailed renamings of assignable concrete/interface types.
+//
+// We reject renamings initiated at concrete methods if it would
+// change the assignability relation. For renamings of abstract
+// methods, we rename all methods transitively coupled to it via
+// assignability.
func (r *renamer) checkMethod(from *types.Func) {
// e.g. error.Error
if from.Pkg() == nil {
diff --git a/refactor/rename/spec.go b/refactor/rename/spec.go
index 0c4526d..22a268a 100644
--- a/refactor/rename/spec.go
+++ b/refactor/rename/spec.go
@@ -31,7 +31,6 @@
//
// It is populated from an -offset flag or -from query;
// see Usage for the allowed -from query forms.
-//
type spec struct {
// pkg is the package containing the position
// specified by the -from or -offset flag.
@@ -413,7 +412,6 @@
// spec.fromName matching the spec. On success, the result has exactly
// one element unless spec.searchFor!="", in which case it has at least one
// element.
-//
func findObjects(info *loader.PackageInfo, spec *spec) ([]types.Object, error) {
if spec.pkgMember == "" {
if spec.searchFor == "" {
@@ -572,6 +570,7 @@
}
// Matches cgo generated comment as well as the proposed standard:
+//
// https://golang.org/s/generatedcode
var generatedRx = regexp.MustCompile(`// .*DO NOT EDIT\.?`)
diff --git a/refactor/rename/util.go b/refactor/rename/util.go
index e8f8d74..258ba78 100644
--- a/refactor/rename/util.go
+++ b/refactor/rename/util.go
@@ -83,7 +83,6 @@
// sameFile returns true if x and y have the same basename and denote
// the same file.
-//
func sameFile(x, y string) bool {
if runtime.GOOS == "windows" {
x = filepath.ToSlash(x)
diff --git a/refactor/satisfy/find.go b/refactor/satisfy/find.go
index 34b349e..ff4212b 100644
--- a/refactor/satisfy/find.go
+++ b/refactor/satisfy/find.go
@@ -14,7 +14,6 @@
// functionality will become part of the type-checker in due course,
// since it is computing it anyway, and it is robust for ill-typed
// inputs, which this package is not.
-//
package satisfy // import "golang.org/x/tools/refactor/satisfy"
// NOTES:
@@ -69,7 +68,6 @@
// that is checked during compilation of a package. Refactoring tools
// will need to preserve at least this part of the relation to ensure
// continued compilation.
-//
type Finder struct {
Result map[Constraint]bool
msetcache typeutil.MethodSetCache
@@ -88,7 +86,6 @@
// The package must be free of type errors, and
// info.{Defs,Uses,Selections,Types} must have been populated by the
// type-checker.
-//
func (f *Finder) Find(info *types.Info, files []*ast.File) {
if f.Result == nil {
f.Result = make(map[Constraint]bool)
@@ -276,7 +273,6 @@
// explicit conversions and comparisons between two types, unless the
// types are uninteresting (e.g. lhs is a concrete type, or the empty
// interface; rhs has no methods).
-//
func (f *Finder) assign(lhs, rhs types.Type) {
if types.Identical(lhs, rhs) {
return
diff --git a/txtar/archive.go b/txtar/archive.go
index 2142566..81b3145 100644
--- a/txtar/archive.go
+++ b/txtar/archive.go
@@ -6,15 +6,15 @@
//
// The goals for the format are:
//
-// - be trivial enough to create and edit by hand.
-// - be able to store trees of text files describing go command test cases.
-// - diff nicely in git history and code reviews.
+// - be trivial enough to create and edit by hand.
+// - be able to store trees of text files describing go command test cases.
+// - diff nicely in git history and code reviews.
//
// Non-goals include being a completely general archive format,
// storing binary data, storing file modes, storing special files like
// symbolic links, and so on.
//
-// Txtar format
+// # Txtar format
//
// A txtar archive is zero or more comment lines and then a sequence of file entries.
// Each file entry begins with a file marker line of the form "-- FILENAME --"