mirror of
https://github.com/golang/go
synced 2024-11-24 06:40:17 -07:00
cmd/go: don't try to print build info of non-Go binaries
On a non-nil err, buildinfo.ReadFile will always return a nil *Buildinfo. In scanFile, we need to return early if that happens. Fixes #49181 Change-Id: I354348d206ab084804937c6f922eadb61435e7b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/359154 Trust: Alberto Donizetti <alb.donizetti@gmail.com> Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
parent
6b3f4d388f
commit
6e481c0b36
@ -151,6 +151,7 @@ func scanFile(file string, info fs.FileInfo, mustPrint bool) {
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", file, err)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("%s: %s\n", file, bi.GoVersion)
|
||||
|
9
src/cmd/go/testdata/script/go_version.txt
vendored
Normal file
9
src/cmd/go/testdata/script/go_version.txt
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# test that go version doesn't panic on non-go binaries
|
||||
# See Issue #49181
|
||||
|
||||
[exec:/bin/true] cp /bin/true true
|
||||
[exec:C:\windows\system32\help.exe] cp C:\windows\system32\help.exe help.exe
|
||||
|
||||
go version -m .
|
||||
! stdout .
|
||||
! stderr .
|
Loading…
Reference in New Issue
Block a user