x/pkgsite docs wrongly assume $PATH includes $GOPATH/bin

199 views
Skip to first unread message

Robert Sawicki

unread,
Feb 28, 2024, 7:39:22 PM2/28/24
to golang-nuts
Hey!

As I was looking through Go docs recently, I've noticed docs for x/pkgsite wrongly assume that user's $PATH includes $GOPATH/bin, by using `pkgsite` as a way to launch the command right after installing it.

Golang installation docs only mention adding /usr/local/bin/go to $PATH, so I believe this may be confusing for new users. At least it was to me.

Shouldn't these docs explicitly state that they assume that path is added to $PATH, just for clarity's sake? Or maybe adding $GOPATH/bin (or $GOBIN) to user's $PATH is a worthy addition to installation docs?

I decided to ask here, since I don't want to create a whole Github issue just for something like that. If this gains traction, I'm willing to create such an issue.

Axel Wagner

unread,
Feb 29, 2024, 12:18:07 AM2/29/24
to Robert Sawicki, golang-nuts
Doesn't the `go install` command explicitly instruct you to add $GOBIN/$GOPATH/bin to your $PATH? To me, that seems enough - it feels a bit arduous, to expect this piece of information at any single point on the web where `go install` is mentioned.

--
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/53386532-7bd4-421a-9f41-b973dbfa68ean%40googlegroups.com.

kredop...@gmail.com

unread,
Feb 29, 2024, 3:12:00 AM2/29/24
to golang-nuts
Apologies - sent the response only to you, so I'll write it again here.

> Doesn't the `go install` command explicitly instruct you to add $GOBIN/$GOPATH/bin to your $PATH?

I did check both golang installation docs and the output of `go help install` - it's very possible I'm missing something, but I didn't find any mention of adding $GOBIN/$GOPATH to the $PATH. Am I just looking in the wrong place?

> To me, that seems enough - it feels a bit arduous, to expect this piece of information at any single point on the web where `go install` is mentioned.

I wholeheartedly agree - as long as the information mentioned above is visible somewhere else, possibly in at least one of the two places I've just listed. I was simply surprised that, possibly due to unskillful searches of mine, I didn't find official sources suggesting adding $GOBIN/$GOPATH to the $PATH, which may be confusing, especially when package docs assume this has been done.

Also, thanks for the quick reply!

Axel Wagner

unread,
Feb 29, 2024, 3:25:00 AM2/29/24
to kredop...@gmail.com, golang-nuts
On Thu, Feb 29, 2024 at 9:12 AM kredop...@gmail.com <kredop...@gmail.com> wrote:
Apologies - sent the response only to you, so I'll write it again here.

> Doesn't the `go install` command explicitly instruct you to add $GOBIN/$GOPATH/bin to your $PATH?

I did check both golang installation docs and the output of `go help install` - it's very possible I'm missing something, but I didn't find any mention of adding $GOBIN/$GOPATH to the $PATH. Am I just looking in the wrong place?

No, I misremembered. I mixed it up with make.bash (the script used to build Go itself).
Perhaps it would be useful if `go install` would check if $GOBIN is in your $PATH and print a warning, if not? It's already somewhat verbose (it prints any dependencies it needs to download), so I feel that the usual "it should be silent on success" logic doesn't apply and there would be little harm.
 

> To me, that seems enough - it feels a bit arduous, to expect this piece of information at any single point on the web where `go install` is mentioned.

I wholeheartedly agree - as long as the information mentioned above is visible somewhere else, possibly in at least one of the two places I've just listed. I was simply surprised that, possibly due to unskillful searches of mine, I didn't find official sources suggesting adding $GOBIN/$GOPATH to the $PATH, which may be confusing, especially when package docs assume this has been done.

Also, thanks for the quick reply!

On Thursday 29 February 2024 at 06:18:07 UTC+1 Axel Wagner wrote:
Doesn't the `go install` command explicitly instruct you to add $GOBIN/$GOPATH/bin to your $PATH? To me, that seems enough - it feels a bit arduous, to expect this piece of information at any single point on the web where `go install` is mentioned.

On Thu, Feb 29, 2024 at 1:39 AM Robert Sawicki <kredop...@gmail.com> wrote:
Hey!

As I was looking through Go docs recently, I've noticed docs for x/pkgsite wrongly assume that user's $PATH includes $GOPATH/bin, by using `pkgsite` as a way to launch the command right after installing it.

Golang installation docs only mention adding /usr/local/bin/go to $PATH, so I believe this may be confusing for new users. At least it was to me.

Shouldn't these docs explicitly state that they assume that path is added to $PATH, just for clarity's sake? Or maybe adding $GOPATH/bin (or $GOBIN) to user's $PATH is a worthy addition to installation docs?

I decided to ask here, since I don't want to create a whole Github issue just for something like that. If this gains traction, I'm willing to create such an issue.

--
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/53386532-7bd4-421a-9f41-b973dbfa68ean%40googlegroups.com.

--
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.

kredop...@gmail.com

unread,
Feb 29, 2024, 7:59:34 PM2/29/24
to golang-nuts
I've created an issue for this on Golang's Github, let's see where that goes. I went for the "let's add to the docs first" approach for now.

Thanks for the convo!
Reply all
Reply to author
Forward
0 new messages