在github上发布基于golang的二进制文件,并使用“ go get”安装

在github上发布基于golang的二进制文件,并使用“ go get”安装

问题描述:

I created a simple lazy package manager for go. I published it at https://github.com/kfirufk/glpm.

when I execute go get github.com/kfirufk/glpm I get no errors, but it compiles it as a module since the resulted pkg content at $GOPATH/pkg/darwin_amd64/github.com/kfirufkis glpm.a.

I want it to be compiled as an executable. what am I missing?

thanks

我为go创建了一个简单的惰性包管理器。 我在 https://github.com/kfirufk/glpm 。 p>

当我执行 go github时 .com / kfirufk / glpm code>我没有收到任何错误,但它将其编译为模块,因为 $ GOPATH / pkg / darwin_amd64 / github.com / kfirufk code>中生成的pkg内容是 glpm.a 代码>。 p>

我希望将其编译为可执行文件。 我想念什么? p>

谢谢 p> div>

To get your project building as an executable, you need to have:

  • All of the buildable Go files as part of the package main, and
  • Define a main function to be the entry point for your program

However, if your package can also be used as a library, a common pattern is to have your executable stored in $PACKAGE/cmd/$EXECUTABLE_NAME. This would mean your package executable would be fetched using:

go get -u github.com/kfirufk/glpm/cmd/glpm