go build ./... does build you program. I think most people would be a bit surprised if it did something other than build.
If you don't want to build your program, but just vet that they are syntactically correct then maybe try something like go vet ./... On Monday, 19 April 2021 at 16:36:14 UTC+1 tapi...@gmail.com wrote: > Thanks for the information. > > Personally, I think the behavior is hard to predict. The binary should be > only produced when a single path is specified. > > On Monday, April 19, 2021 at 10:59:33 AM UTC-4 Brian Candler wrote: > >> In short, yes this is as intended, although somewhat obscure. The >> documentation is here >> <https://golang.org/cmd/go/#hdr-Compile_packages_and_dependencies>: >> >> *"When compiling a single main package, build writes the resulting >> executable to an output file named after the first source file ('go build >> ed.go rx.go' writes 'ed' or 'ed.exe') or the source code directory ('go >> build unix/sam' writes 'sam' or 'sam.exe'). The '.exe' suffix is added when >> writing a Windows executable.* >> >> *When compiling multiple packages or a single non-main package, build >> compiles the packages but discards the resulting object, serving only as a >> check that the packages can be built.* >> >> *The -o flag forces build to write the resulting executable or object to >> the named output file or directory, instead of the default behavior >> described in the last two paragraphs."* >> For me I had the problem the other way >> <https://groups.google.com/g/golang-nuts/c/JvHa4EEVEQo/m/XNlspgAyAgAJ>: >> "go build ./..." was happily building the binary when there was only one >> main package, but stopped working when I added a second. The solution for >> me was "go build -o . ./..." >> >> Sorry but I don't know how to make go build with a single main package >> discard the output. I'd be inclined to make use of .gitignore >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f3e969b6-09f3-4063-91ee-b5e831782cf5n%40googlegroups.com.