1
0
mirror of https://github.com/golang/go synced 2024-11-17 03:14:50 -07:00

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í <mvdan@mvdan.cc>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Daniel Martí 2023-04-08 22:52:21 +01:00
parent 45c0a7f27e
commit 594d67b540

View File

@ -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