How to build Golang executable with different name other than Golang package name?

How to build Golang executable with a different name other than the Golang package name?

Just use this:

go build -o [your desired executable name]

You can specify the executable name using the -o switch with go build.

For your example it would look something like: cd $GOPATH/github.com/username/go-foobar && go build -o foobar .