GoDoc in Local
In your preferred directory, initialize GOPATH using the short script in Suggested GoLang Init Script.
Then, do the following steps:
- Install godoc
1~$ go install golang.org/x/tools/cmd/godoc@latest
2go: downloading golang.org/x/tools v0.1.7
3go: downloading golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e
4go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
5go: downloading golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d
6go: downloading github.com/yuin/goldmark v1.4.0
7go: downloading golang.org/x/mod v0.4.2
- Run godoc
It defaults to using port 6060.
If default port has a conflict, replace it by using parameter -http=:NNNN
where NNNN is your port number.
Example, if port 9999
is available, you can run godoc as follows:
- In your browser, you can now go to http://localhost:6060/pkg/ or whatever custom port you used.