Re: default package names and hyphens

1,436 views
Skip to first unread message

Martin Angers

unread,
May 21, 2013, 1:50:18 PM5/21/13
to golan...@googlegroups.com
The default package name is the name defined in the source code of the imported package. It can be totally different from the last path component of the import part (say, like mgo/v2). Sometimes you see a package's import path ending with go-whatever, but in the source code, the package is only whatever.

Of course you can import under a different name if you wish.

Le mardi 21 mai 2013 11:19:09 UTC-4, Will Norris a écrit :
I know that the default name for an imported package is the last path component in the full package name.  So "a/b/c" is, by default, imported using the name "c".  

However, I just realized that go will split on hyphens as well.  So "a/b-c" is, by default, also imported using the name "c".  I've never seen this documented anywhere, so wanted to confirm that this is in fact intended behavior that won't be accidentally removed at some point.  Is it generally acceptable to use this naming convention, or is it discouraged?  (it does generally help clean up the imports of many packages that are named "go-package").

Thanks.
Reply all
Reply to author
Forward
0 new messages