Re:Introduction to Go 1.1
by lobster_johnson on Tuesday March 26, 2013 @05:50PM
(#5446297)
True, although it gets annoying having to "rename" a package like this. If it's a package you use everywhere in your project, it gets old fast; canonical, author-defined names are always the best option.
Yes, it could be a pain unless it was just imported in one or two files. In practice though I've not found collisions in package names to be an issue, simply because of the layering of packages - the top level package is really the only one which knows about these adapters and imports them - it then presents an interface to the world which is under its namespace, so the only worry for uniqueness is the top level pkg name really.
So I'm using obvious names, with the pkg (say core) in one folder, and subpkg in the subfolder named adapters.
this has a few .go files in it to split things up into different concerns, and a subpackage with adapters (again with a few files), imported with: and using adapters.XXX in the core code. You can also do this: and use mypkg.XXX to refer to the subpackage, so you're not tied to the folder names for package import names, that's just the convention, and if someone needs to rewrite the name on import, they can do so.