]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gofmt: apply a correct suggestion by gopls
authorDaniel Martí <mvdan@mvdan.cc>
Sat, 8 Apr 2023 21:52:21 +0000 (22:52 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 13 Apr 2023 15:25:51 +0000 (15:25 +0000)
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>

src/cmd/gofmt/gofmt.go

index 00c8cbdb939d00a62280e31425a7e17715729e67..bb22aea03144acc0dc2618ddb8443f5fbff9262e 100644 (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