无法去获取离线教程

I am trying to run the command go get golang.org/x/tour tour but I am getting the error message "package tour: unrecognized import path "tour" (import path does not begin with hostname)". I also do not get the binary in my bin folder that is mentioned.

Things I have attempted to resolve the issue:

  • Read the documentation at https://golang.org/doc/code.html and https://golang.org/doc/install.
  • Verify workspace folders exist as specified in documentation (my workspace is /home/USERNAME/go, and inside that I have created 2 folders src and bin).
  • changed command from go get golang.org/x/tour tour to go get golang.org/x/tour /home/USERNAME/go (still get a simillar import path error message)
  • verified that my go path is set correctly and go is installed using defaults, my go path in /etc/profile is /usr/local/go/bin
  • since the command did create a directory called golang.org, I navigated to /home/USERNAME/go/src/golang.org/x/tour and ran go build tour.go. I got the errors:

    # command-line-arguments
    ./tour.go:62:4: undefined: socketAddr
    ./tour.go:126:28: undefined: prepContent
    
  • read the README.md in the golang.org/x/tour folder

  • change bin permissions to 755

Syntax of go get is (run go help get to see):

usage: go get [-d] [-f] [-t] [-u] [-v] [-fix] [-insecure] [build flags] [packages]

Everything you list at the end are all packages to get. So you should simply run:

go get golang.org/x/tour

Note: there is no need to pass an additional tour parameter. This is what the error message tells you: the tour package is not recognized.

The above command will get the golang.org/x/tour and install it into your $GOPATH/bin, so you can simply run it after the above command like:

$GOPATH/bin/tour

After go get golang.org/x/tour

Run go build

This will generate executable which on run start local tour at http://127.0.0.1:3999/