当前位置: 动力学知识库 > 问答 > 编程问答 >

windows - How to build binary in package in 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 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"

网友答案:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: