From: Andrew Gerrand Date: Mon, 16 Sep 2013 01:19:39 +0000 (+1000) Subject: cmd/gofmt: document -s transformations X-Git-Tag: go1.2rc2~212 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d445b76331aa342711b79dd6796cd832e9766c26;p=gostls13.git cmd/gofmt: document -s transformations R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/13721043 --- diff --git a/src/cmd/gofmt/doc.go b/src/cmd/gofmt/doc.go index fffc7f06ea..94e67fd89e 100644 --- a/src/cmd/gofmt/doc.go +++ b/src/cmd/gofmt/doc.go @@ -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