Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

godoc command not found after install #653

Open
ruthmoog opened this issue Apr 3, 2023 · 3 comments
Open

godoc command not found after install #653

ruthmoog opened this issue Apr 3, 2023 · 3 comments

Comments

@ruthmoog
Copy link
Collaborator

ruthmoog commented Apr 3, 2023

in chapter Hello World, after the install for godoc terminal does now allow the godoc command.
Instruction should be updated or removed.

ruthmoog hello % go install golang.org/x/tools/cmd/godoc@latest
go: downloading golang.org/x/tools v0.7.0
go: downloading golang.org/x/sys v0.6.0
go: downloading github.com/yuin/goldmark v1.4.13
go: downloading golang.org/x/mod v0.9.0
ruthmoog hello % godoc -http:8000                              
zsh: command not found: godoc
@microwavestine
Copy link

microwavestine commented Jun 13, 2023

After googling around, I found out this is issue with $PATH. When you install go install golang.org/x/tools/cmd/godoc@latestthe binary is installed to (on Mac) /User/[username]/go/bin so you have to set $PATH for this directory. It probably happened because $GOPATH wasn't set properly during Install Go section.

@Battlesheepu
Copy link
Contributor

Battlesheepu commented Feb 28, 2024

I've noticed this problem after browsing through docs - official Go instructions do not include any information about adding the $GOPATH/bin to user's $PATH. Maybe we should add this to the tutorial?

Another, minor thing - it seems godoc has been replaced by pkgsite, too. Is that worthy of a new issue/MR?

After googling around, I found out this is issue with $PATH. When you install go install golang.org/x/tools/cmd/godoc@latestthe binary is installed to (on Mac) /User/[username]/go/bin so you have to set $PATH for this directory. It probably happened because $GOPATH wasn't set properly during Install Go section.

@microwavestine - isn't that expected behaviour based on the go help install output? (also, sorry for tagging you almsot a year after your comment)

Executables are installed in the directory named by the GOBIN environment
variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH
environment variable is not set. Executables in $GOROOT
are installed in $GOROOT/bin or $GOTOOLDIR instead of $GOBIN.

I don't think $GOPATH is, at any stage, added automatically to $PATH by the Go install process (or suggested to be added by the docs, which limit addition to $PATH to /usr/local/go/bin). So this is rather an omission on the part of the docs than something not being set properly if I understand correctly, would you agree?

@microwavestine
Copy link

@Battlesheepu Yup, that's the expected behavior but I wasn't aware of it until I came across this issue. I believe this part in Install Go section of docs was misleading for beginners like me (who never had GOPATH set before):

This approach is the default build mode since Go 1.16, therefore the use of GOPATH is not recommended.

I haven't followed through tutorial for too long... thanks for raising the issue and keeping it updated.

zacharysyoung added a commit to zacharysyoung/learn-go-with-tests that referenced this issue Aug 6, 2024
quii added a commit that referenced this issue Nov 22, 2024
* godoc --> pkgsite; #653 and #691

* added notes about go install and $PATH

* grammar fix

---------

Co-authored-by: Chris James <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants