Installing a package with an associated command

2,938 views
Skip to first unread message

christoph...@gmail.com

unread,
May 25, 2022, 2:13:58 AM5/25/22
to golang-nuts
I have a small package (https://github.com/chmike/clog) that also contains a command in the cmd subdirectory (clogClr). How do I install the clog package and the command ? 

When I execute "go install github.com/chmike/clog@latest" I get the error message that it is not a main package. When I use go get that package is installed, but not the command (clogClr). 

I understand that for security purpose installing a package should not automatically install an executable binary. 

For now I do a git clone and a "go install ./...". It's fine for me, not for an end user. I assume there is a better way. 

Volker Dobler

unread,
May 25, 2022, 2:40:04 AM5/25/22
to golang-nuts
If you want the command to be installed: Why don't you install
_the_ _command_ with 
? (Note that there is no need to install the package.)

V.

christoph...@gmail.com

unread,
May 25, 2022, 3:50:15 AM5/25/22
to golang-nuts
Indeed, it works. What if there are multiple binaries to install ? Does the user have to type the full package name for each program he want to install ?

Isn’t there an equivalent to "go install ./..." that installs everything in one simple and short instruction ?

Peter Galbavy

unread,
May 25, 2022, 4:23:22 AM5/25/22
to golang-nuts
It's worth noting that @latest only works for "releases" and not for tags/releases labelled pre-release. Just in case anyone hits the same issue I did a while back! :)

Sean Liao

unread,
May 25, 2022, 6:03:13 AM5/25/22
to golang-nuts
`go install github.com/your/repo/cmd/...@latest` should work

replace `latest` with specific versions (eg prereleases) if necessary

- sean

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/58eb2ba5-b44c-45b5-909e-b6cf85c65bd8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages