I'm just getting started with Go. I use subversion for most of my development, but the Go tutorial seems to assume that everything is hosted on Github in either a public repository or a (paid) private repository. It looks like I'm forced to choose between:
Am I missing something here, or is this really the case?
go get
supports most git, mercurial, bazaar & svn repos, so your own Git server, Bitbucket, GitLab, etc are all acceptable. This is touched on in the docs here: https://golang.org/doc/code.html#PackagePaths
Similarly, you can just create a $GOPATH/src/yourname/yourpkg
dir, but you will have a harder time sharing your code with others.
In addition, you can use remote import paths (aka "vanity domains") to allow go get scott.com/pkg/usefulthing
instead of directly pointing to GitHub, etc. Useful as you can avoid being tied to a single platform, should you wish to move in the future.
"go get" and the "import" statement both support several remote repositories, including:
as well as syntax for code hosted on other servers:
For code hosted on other servers, import paths may either be qualified with the version control type, or the go tool can dynamically fetch the import path over https/http and discover where the code resides from a <meta> tag in the HTML.
To declare the code location, an import path of the form
repository.vcs/path specifies the given repository, with or without the .vcs suffix, using the named version control system, and then the path inside that repository. The supported version control systems are:
- Bazaar .bzr
- Git .git
- Mercurial .hg
- Subversion .svn
You don't need to be on Github yourself to use other available repos on Github. Bitbucket offers unlimited private repositories. You can even choose to have a completely local git repository (not using any git hosting service), and still use repos available on Github.