2 ms·
> If you write a package, it will have a name. A unique one. In all the universe. How does that work?
by theseoafs 13y ago
> If you write a package, it will have a name. A unique one. In all the universe.
How does that work?
- robert_tweed 13y agoSame way it works in Java: by convention. You use the repository URL on e.g., github in the package name, so if that URL is unique then your package name is unique. It rather relies on the assumption that you do have one unique canonical URL associated with your package for this to work, but one of the things about go is that a lot of it is based on pragmatic assumptions that turn out to be true often enough that the edge cases don't matter. If you use go get, it can auto-download any such publicly hosted packages, which is a nice feature, especially as it can get the dependencies for you as well.
- mholt 13y agoThe fully-qualified package name, by convention, includes the web path to its repository, for example: `github.com/smartystreets/go-aws-auth` is unique.
- mediocregopher 13y agoBasically to install a dependency you do something like "go get github.com/mediocregopher/somelib", and the tool will fetch it and put in the appropriate spot on your GOPATH. So the universal name of your package is also the address the package is retrieved from. You COULD host the package multiple places and it wouldn't be true that it would be unique in the whole universe, but that's up to you.