How to build a binary package in the Golang?

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 a package in my project. When I:

 $ cd github.com/user/project/sub1 $ go build 

Nothing happens. Go build seems to end without complaint, but there is no executable. How can I create packages in an executable?

"go version go1.3 windows / amd64"

+5
source share
1 answer

It doesn’t matter whether you specify your main.go or shubudoo.go . The only thing that is important if you want to create an executable file (command) is that your files start with package main . One more thing: Go has absolutely no concept of "subpackage": all packages are equal for the compiler. File system nesting is for your convenience only.

+6
source

Source: https://habr.com/ru/post/1212904/


All Articles