In Windows 10, deploy a local document to browse the web server process (godoc.exe is missing)
1. The Go doc tool can only obtain the comments in ../go/src in the go installation directory. In addition, it can also be used as a local document to browse the web server. Enter godoc -http=:6060 on the command line and open it with a browserhttp://localhost:6060After that, you can see the page provided by the local document browsing server. Reference URL:https://github.com/unknwon/the-way-to-go_ZH_CN/blob/master/eBook/03.6.md
2. Run godoc -http=:6060 on the command line, and an error is reported: The “godoc” item cannot be recognized as a cmdlet, a function, a script file or a runable program name. Please check the spelling of the name, if the path is included, make sure the path is correct and try again. as shown in Figure 1
PS C:\Go> godoc -http=:6060
godoc : 无法将“godoc”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正
确,然后再试一次。
所在位置 行:1 字符: 1
+ godoc -http=:6060
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (godoc:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
3. Enter the c:\go\bin directory to view the file and find that godoc.exe does not exist
PS C:\Go> cd bin
PS C:\Go\bin> ls
目录: C:\Go\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2019/10/31 22:59 14797824 go.exe
-a---- 2019/10/31 22:59 3715072 gofmt.exe
4. Check the Go version, execute the command: Go version, refer to the URL:https://golang.org/doc/go1.13#godoc, the Godoc web server is no longer included in the main binary distribution. To run the Godoc web server locally, you need to install it manually first.
PS C:\Go> go version
go version go1.13.4 windows/amd64
5. Go install compiles and installs its own package and dependency package, go install golang.org/x/tools/cmd/godoc,https://github.com/golang/tools/tree/master/godoc. , the reference URL:https://www.shuijingwanwq.com/2019/12/28/3784/to solve the error message.
PS C:\Go> go install golang.org/x/tools/cmd/godoc
C:\Users\Administrator\go\src\golang.org\x\tools\cmd\godoc\main.go:47:2: cannot find package "golang.org/x/xerrors" in a
ny of:
c:\go\src\golang.org\x\xerrors (from $GOROOT)
C:\Users\Administrator\go\src\golang.org\x\xerrors (from $GOPATH)
PS C:\Go> set HTTP_PROXY=http://127.0.0.1:50999
PS C:\Go> set HTTPS_PROXY=http://127.0.0.1:50999
PS C:\Go> go install golang.org/x/tools/cmd/godoc
go: downloading golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
go: extracting golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898
6. Run godoc -http=:6060 again on the command line, success
PS C:\Go> godoc -http=:6060
using GOPATH mode
7. Use the browser to openhttp://localhost:6060, open normally, in line with expectations, as shown in Figure 2
8. Enter the c:\go\bin directory to view the file, and find that godoc.exe still does not exist. Enter the c:\Users\Administrator\Go\bin directory and find that Godoc.exe already exists, which is in line with expectations, as shown in Figure 3
PS C:\Go> cd C:\Go\bin
PS C:\Go\bin> ls
目录: C:\Go\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2019/10/31 22:59 14797824 go.exe
-a---- 2019/10/31 22:59 3715072 gofmt.exe
PS C:\Go\bin> cd C:\Users\Administrator\go\bin
PS C:\Users\Administrator\go\bin> ls
目录: C:\Users\Administrator\go\bin
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 2020/02/20 18:17 16660480 godoc.exe
-a---- 2020/02/20 18:34 14633984 tour.exe


