mirror of
https://github.com/golang/go
synced 2024-11-22 20:14:40 -07:00
cmd/go/internal/work/exec: throw an error when buildP is negative
Fixed a problem where an error would not occur
when a negative value was specified for the p flag.
`go build -p=0`
now should throw an error.
this is my first pr to this project.
If there's anything I'm missing, please let me know 🙏
Fixes #46686
Change-Id: I3b19773ef095fad0e0419100d317727c2268699a
GitHub-Last-Rev: e5c57804d9
GitHub-Pull-Request: golang/go#47360
Reviewed-on: https://go-review.googlesource.com/c/go/+/336751
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
0c83e01e0c
commit
4a0fd73ead
@ -40,6 +40,10 @@ func BuildInit() {
|
||||
cfg.BuildPkgdir = p
|
||||
}
|
||||
|
||||
if cfg.BuildP <= 0 {
|
||||
base.Fatalf("go: -p must be a positive integer: %v\n", cfg.BuildP)
|
||||
}
|
||||
|
||||
// Make sure CC, CXX, and FC are absolute paths.
|
||||
for _, key := range []string{"CC", "CXX", "FC"} {
|
||||
value := cfg.Getenv(key)
|
||||
|
5
src/cmd/go/testdata/script/build_negative_p.txt
vendored
Normal file
5
src/cmd/go/testdata/script/build_negative_p.txt
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
! go build -p=-1 example.go
|
||||
stderr 'go: -p must be a positive integer: -1'
|
||||
|
||||
-- example.go --
|
||||
package example
|
Loading…
Reference in New Issue
Block a user