]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gofmt: document -s transformations
authorAndrew Gerrand <adg@golang.org>
Mon, 16 Sep 2013 01:19:39 +0000 (11:19 +1000)
committerAndrew Gerrand <adg@golang.org>
Mon, 16 Sep 2013 01:19:39 +0000 (11:19 +1000)
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/13721043

src/cmd/gofmt/doc.go

index fffc7f06ea086d09d6f2eb17a16e6de253d8dd99..94e67fd89ee6d585bf3d85c76cc95eb80e2a6784 100644 (file)
@@ -71,6 +71,25 @@ To remove the parentheses:
 To convert the package tree from explicit slice upper bounds to implicit ones:
 
        gofmt -r 'α[β:len(α)] -> α[β:]' -w $GOROOT/src/pkg
+
+The simplify command
+
+When invoked with -s gofmt will make the following source transformations where possible.
+
+       An array, slice, or map composite literal of the form:
+               []T{T{}, T{}}
+       will be simplified to:
+               []T{{}, {}}
+
+       A slice expression of the form:
+               s[a:len(s)]
+       will be simplified to:
+               s[a:]
+
+       A range of the form:
+               for x, _ = range v {...}
+       will be simplified to:
+               for x = range v {...}
 */
 package main