Golang, importing packages from Github requests me to remember the Github URL?

I'm very new to Golang. I see that in Golang you can import packages directly from Github like:

import "github.com/MakeNowJust/heredoc"

Does that mean I have to remember this URL in order to use this package? IMHO this is not cool. What if later the author of the package removed it or changed the URL? Any ideas?


I would recommend you to read the How to Write Go Code documentation and this blog post.

The path you're seeing in your import line is not a url, but only the path the package is located in (normally relative to $GOROOT/src/pkg or $GOPATH/src). So your package heredoc is most probably located in the directory $GOPATH/src/github.com/MakeNowJust/heredoc.

The recommended way to use external packages is by downloading and installing them via go get. You might want to check out the documentation of go get by go get --help.


The path that import statement refers is just appended to $GOPATH/src. So that import statement basically says "import the package located at $GOPATH/src/github.com/MakeNowJust/heredoc"

What if later the author of the package removed it or changed the URL?

As long as you already have the source files for that package at the expected location, it should be included even if the repo has moved.