From: Daniel Martí Date: Sat, 8 Apr 2023 21:52:21 +0000 (+0100) Subject: cmd/gofmt: apply a correct suggestion by gopls X-Git-Tag: go1.21rc1~916 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=594d67b54095ea63883e2c0dbb3639a9f86f115a;p=gostls13.git cmd/gofmt: apply a correct suggestion by gopls I wrote this code a couple of years back, and it's unnecessarily verbose for sure. Change-Id: I684376bf81a995594d90e4faf4deaa2cf51181c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/483296 Run-TryBot: Daniel Martí Reviewed-by: David Chase Reviewed-by: Robert Griesemer TryBot-Result: Gopher Robot --- diff --git a/src/cmd/gofmt/gofmt.go b/src/cmd/gofmt/gofmt.go index 00c8cbdb93..bb22aea031 100644 --- a/src/cmd/gofmt/gofmt.go +++ b/src/cmd/gofmt/gofmt.go @@ -233,12 +233,9 @@ func processFile(filename string, info fs.FileInfo, in io.Reader, r *reporter) e } fileSet := token.NewFileSet() - fragmentOk := false - if info == nil { - // If we are formatting stdin, we accept a program fragment in lieu of a - // complete source file. - fragmentOk = true - } + // If we are formatting stdin, we accept a program fragment in lieu of a + // complete source file. + fragmentOk := info == nil file, sourceAdj, indentAdj, err := parse(fileSet, filename, src, fragmentOk) if err != nil { return err