在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

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