I have a project in github.com/user called project:
src/
github.com/user/project
sub1/
main.go
sub1.exe (??)
sub2/
main.go
sub2.exe (??)
I am trying to compile the package in my project. When I:
$ cd github.com/user/project/sub1
$ go build
Nothing happens. go build seems to finish without complaining, but there is no executable file. How can I build packages into executable?
"go version go1.3 windows/amd64"
This command does perform the exact operation as go build but places the binary in $GOPATH/bin` directory alongside the binaries of third-party tools installed via go get now if you run $GOPATH/bin/hello you will see Hello, world!
While the go run command is a useful shortcut for compiling and running a program when you're making frequent changes, it doesn't generate a binary executable.
Go Binaries is an open-source server allowing non-Go users to quickly install tools written in Golang, without installing the Go compiler or a package manager — all you need is curl .
To build an executable, the command would take this form: GOOS= target-OS GOARCH= target-architecture go build package-import-path.
It doesn't matter if you name your file main.go or shubudoo.go. The only thing what matters if you want to build an executable (a command) is that your files start with package main. One more thing: Go has absolutely no notion of "subpackage": All packages are equal for the compiler. The filesystem nesting is for your convenience only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With