Skip to content

Commit 4a0fd73

Browse files
Yuuki77Jay Conrod
authored and
Jay Conrod
committed
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: e5c5780 GitHub-Pull-Request: #47360 Reviewed-on: https://go-review.googlesource.com/c/go/+/336751 Reviewed-by: Jay Conrod <[email protected]> Trust: Jay Conrod <[email protected]> Trust: Bryan C. Mills <[email protected]> Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent 0c83e01 commit 4a0fd73

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/cmd/go/internal/work/init.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ func BuildInit() {
4040
cfg.BuildPkgdir = p
4141
}
4242

43+
if cfg.BuildP <= 0 {
44+
base.Fatalf("go: -p must be a positive integer: %v\n", cfg.BuildP)
45+
}
46+
4347
// Make sure CC, CXX, and FC are absolute paths.
4448
for _, key := range []string{"CC", "CXX", "FC"} {
4549
value := cfg.Getenv(key)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
! go build -p=-1 example.go
2+
stderr 'go: -p must be a positive integer: -1'
3+
4+
-- example.go --
5+
package example

0 commit comments

Comments
 (0)