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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/3cccc7fe-019a-4a03-b3e3-f642bba77bc8n%40googlegroups.com.