diff --git a/doc/go1.11.html b/doc/go1.11.html index 0100c327076..da722fb31a1 100644 --- a/doc/go1.11.html +++ b/doc/go1.11.html @@ -266,8 +266,6 @@ func f(v interface{}) { This is currently only supported by Delve.

-

Tools

-

Test

@@ -312,6 +310,26 @@ func f(v interface{}) { user task/region analysis page.

+

Gofmt

+ +

+ One minor detail of the default formatting of Go source code has changed. + When formatting expression lists with inline comments, the comments were + aligned according to a heuristic. + However, in some cases the alignment would be split up too easily, or + introduce too much whitespace. + The heuristic has been changed to behave better for human-written code. +

+ +

+ Note that these kinds of minor updates to gofmt are expected from time to + time. + In general, systems that need consistent formatting of Go source code should + use a specific version of the gofmt binary. + See the go/format package godoc for more + information. +

+

Runtime

diff --git a/src/go/format/format.go b/src/go/format/format.go index cad5958e5c5..9aa28fc63b2 100644 --- a/src/go/format/format.go +++ b/src/go/format/format.go @@ -3,6 +3,15 @@ // license that can be found in the LICENSE file. // Package format implements standard formatting of Go source. +// +// Note that formatting of Go source code changes over time, so tools relying on +// consistent formatting should execute a specific version of the gofmt binary +// instead of using this package. That way, the formatting will be stable, and +// the tools won't need to be recompiled each time gofmt changes. +// +// For example, pre-submit checks that use this package directly would behave +// differently depending on what Go version each developer uses, causing the +// check to be inherently fragile. package format import ( @@ -79,10 +88,6 @@ func Node(dst io.Writer, fset *token.FileSet, node interface{}) error { // space as src), and the result is indented by the same amount as the first // line of src containing code. Imports are not sorted for partial source files. // -// Caution: Tools relying on consistent formatting based on the installed -// version of gofmt (for instance, such as for presubmit checks) should -// execute that gofmt binary instead of calling Source. -// func Source(src []byte) ([]byte, error) { fset := token.NewFileSet() file, sourceAdj, indentAdj, err := parse(fset, "", src, true)