...
1# go build with -o and -buildmode=exe should report an error on a non-main package.
2
3! go build -buildmode=exe -o out$GOEXE ./not_main
4stderr '-buildmode=exe requires exactly one main package'
5! exists out$GOEXE
6! go build -buildmode=exe -o out$GOEXE ./main_one ./main_two
7stderr '-buildmode=exe requires exactly one main package'
8! exists out$GOEXE
9
10-- go.mod --
11module m
12
13go 1.16
14-- not_main/not_main.go --
15package not_main
16
17func F() {}
18-- main_one/main_one.go --
19package main
20
21func main() {}
22-- main_two/main_two.go --
23package main
24
25func main() {}
View as plain text