在Go中设置包路径

Getting started with Go and going through the docs here: https://golang.org/doc/code.html

The part entitled Package paths recommends using my Github account as a base path. However, with the forward slashes in the GH url, when I run mkdir -p $GOPATH/src/github.com/user it creates a sub-folder. So the example of github.com/user creates:

src/
    github.com/
        user/

but I don't think this is what's intended.

What can I do here?

This is actually the intended behavior,

You can even call go get on a github repo and it will create this same directory structure

The behavior is correct. The packages names in Go provide unique global name space.

github.com/user/repo therefore identifies a package, which is easily go get -able (download and install the package) and also provides much needed separation. You can also create packages without a hostname (in this case github.com) but effectively preventing users from using go get and resorting to manual management.

Having a username in GitHub case allows you to use forks of other libraries and maintain the separation. The full package name is then used for importing

import "github.com/user/repo"