dongqing5575
2016-07-13 20:42
浏览 213
已采纳

在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

图片转代码服务由CSDN问答提供 功能建议

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

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

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

谢谢

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpbl91234 2016-07-13 20:45
    已采纳

    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
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题