GoDoc in Local
Publish date: Nov 5, 2021
In your preferred directory, initialize GOPATH using the short script in Suggested GoLang Init Script.
Then, do the following steps:
- Install godoc
~$ go install golang.org/x/tools/cmd/godoc@latest
go: downloading golang.org/x/tools v0.1.7
go: downloading golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e
go: downloading golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
go: downloading golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d
go: downloading github.com/yuin/goldmark v1.4.0
go: downloading golang.org/x/mod v0.4.2
- Run godoc
~$ godoc
using module mode; GOMOD=/dev/null
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:
~$ godoc -http=:9999
using module mode; GOMOD=/dev/null
- In your browser, you can now go to http://localhost:6060/pkg/ or whatever custom port you used.