From a51b8cf870f5911a9785973a3362e4411d83b17d Mon Sep 17 00:00:00 2001 From: Robert Hencke Date: Thu, 3 Oct 2013 10:55:17 -0700 Subject: [PATCH] gofmt: explain why lower bounds aren't automatically simplified Full credit goes to gri and rsc for their explanations. R=golang-dev, r CC=golang-dev https://golang.org/cl/14229043 --- src/cmd/gofmt/simplify.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cmd/gofmt/simplify.go b/src/cmd/gofmt/simplify.go index e9a67a73ac..45d000d675 100644 --- a/src/cmd/gofmt/simplify.go +++ b/src/cmd/gofmt/simplify.go @@ -90,6 +90,10 @@ func (s *simplifier) Visit(node ast.Node) ast.Visitor { // Note: We could also simplify slice expressions of the form s[0:b] to s[:b] // but we leave them as is since sometimes we want to be very explicit // about the lower bound. + // An example where the 0 helps: + // x, y, z := b[0:2], b[2:4], b[4:6] + // An example where it does not: + // x, y := b[:n], b[n:] case *ast.RangeStmt: // a range of the form: for x, _ = range v {...} -- 2.50.0