]> Cypherpunks repositories - gostls13.git/commit
cmd/go: skip "exclude all Go files" error in fmt
authorDaniel Martí <mvdan@mvdan.cc>
Fri, 3 Nov 2017 18:14:37 +0000 (18:14 +0000)
committerRuss Cox <rsc@golang.org>
Sun, 5 Nov 2017 19:28:13 +0000 (19:28 +0000)
commite5f6051e77b207561dd11ae72cc7451e5ab8bcf3
treeb948f543138a41f08bdbf7a5e8ce8eca3c6d58d8
parentd58d90152ba172dfa52d3135f5fea9b57927e230
cmd/go: skip "exclude all Go files" error in fmt

Otherwise, one can't run "go fmt" on a directory containing Go files if
none of them are buildable (e.g. because of build tags). This is
counter-intuitive, as fmt will format all Go files anyway.

If we encounter such a load error, ignore it and carry on. All other
load errors, such as when a package can't be found, should still be
shown to the user.

Add a test for the two kinds of load errors. Use fmt -n so that any
changes to the formatting of the files in testdata don't actually get
applied. The load errors still occur with -n, so the test does its job.

Fixes #22183.

Change-Id: I99d0c0cdd29015b6a3f5286a9bbff50757c78e0d
Reviewed-on: https://go-review.googlesource.com/75930
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/dist/deps.go
src/cmd/go/go_test.go
src/cmd/go/internal/fmtcmd/fmt.go