How to build executable with name other than Golang package

go build -o <your desired name>

You can specify the executable name using the -o switch with go build. For your example it would look something like:
cd $GOPATH/ && go build -o foobar. However, you’re just left with the executable in the package’s folder — you still need to install it somehow.

However, I don’t know of any way to specify that for someone using go get to install your tool. For instance, see this answer:

If you’re not worried about people installing your tool with go get, this is the kind of thing you can wrap in a Makefile.

Leave a Comment