Is there any reason to NOT name a package with captital letters?

951 views
Skip to first unread message

Hotei

unread,
Feb 2, 2014, 9:35:05 AM2/2/14
to golan...@googlegroups.com
I note that the VAST majority of packages (on godoc.org for example) begin with a lowercase letter.  However the language and implementation allows uppercase package names.   Is there any downside to using an uppercase pkg name?  I've only got a few with leading uppercase, but one of them I use frequently and I don't want to get too far downstream and find there's a subtle problem with that choice.  

Thanks in advance.

Andrew Gerrand

unread,
Feb 2, 2014, 9:42:35 AM2/2/14
to Hotei, golang-nuts
No technical reason that I'm aware of, but it does defy convention. That harms readability.

Andrew


On 2 February 2014 15:35, Hotei <hote...@gmail.com> wrote:
I note that the VAST majority of packages (on godoc.org for example) begin with a lowercase letter.  However the language and implementation allows uppercase package names.   Is there any downside to using an uppercase pkg name?  I've only got a few with leading uppercase, but one of them I use frequently and I don't want to get too far downstream and find there's a subtle problem with that choice.  

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jan Mercl

unread,
Feb 2, 2014, 10:15:44 AM2/2/14
to Hotei, golang-nuts
On Sun, Feb 2, 2014 at 3:35 PM, Hotei <hote...@gmail.com> wrote:

Expanding on Andrew's reply: Uppercase signals "exported entity" (in
the first approximation). However, in the case we're discussing it
doesn't mean that, so I think it introduces cognitive noise. IMHO,
upper case package qualifiers should be thus avoided.

Example of how it matters at eg.
https://github.com/robertkrimen/otto/issues/41#issuecomment-33888773

-j

Hotei

unread,
Feb 2, 2014, 11:19:53 AM2/2/14
to golan...@googlegroups.com
Thanks to Andrew and Jan for your quick response.  I think those are both good points.  Looks like I have a few changes to make.

Dave Cheney

unread,
Feb 2, 2014, 4:51:45 PM2/2/14
to Andrew Gerrand, Hotei, golang-nuts
Mixed case causes all sorts of issues on windows and OSX. On those systems Package and package refer to the same thing. 

Francisco Souza

unread,
Feb 2, 2014, 7:39:53 PM2/2/14
to Dave Cheney, Andrew Gerrand, Hotei, golang-nuts
On Sun, Feb 2, 2014 at 7:51 PM, Dave Cheney <da...@cheney.net> wrote:
> Mixed case causes all sorts of issues on windows and OSX. On those systems
> Package and package refer to the same thing.

It get's worse: it's optional on osx.

Hotei

unread,
Feb 2, 2014, 9:54:21 PM2/2/14
to golan...@googlegroups.com
Seeking clarity on this - would a camelCase package name cause the same issues?  Sounds like it would, but I both camel and upper named packages in a mixed go environment (65% Linux, 30% FreeBSD, 5% Windows7) and have yet to run into any problems.  Several of my utility package names are camelCase and the most frequently used one is upper only.  I'm changing them to increase interoperability, but it it's this big an issue maybe go vet needs to bark about it?  Since it's legal (spec-wise) that may be about all one can hope for. 

I'm also assuming this conventional proscription on mixed case also applies to the import path as well as the package name.  


Caleb Spare

unread,
Feb 2, 2014, 9:59:28 PM2/2/14
to Hotei, golang-nuts
The convention is for package names to be a single word.

If they cannot be, they are written in all-lowercase without any separation between words. In the stdlib:

index/suffixarray
text/tabwriter

The only common exception I'm aware of is putting tests in a foo_test package (if it's decided not to just put them in package foo directly).

-Caleb


On Sun, Feb 2, 2014 at 6:54 PM, Hotei <hote...@gmail.com> wrote:
Seeking clarity on this - would a camelCase package name cause the same issues?  Sounds like it would, but I both camel and upper named packages in a mixed go environment (65% Linux, 30% FreeBSD, 5% Windows7) and have yet to run into any problems.  Several of my utility package names are camelCase and the most frequently used one is upper only.  I'm changing them to increase interoperability, but it it's this big an issue maybe go vet needs to bark about it?  Since it's legal (spec-wise) that may be about all one can hope for. 

I'm also assuming this conventional proscription on mixed case also applies to the import path as well as the package name.  


Dave Cheney

unread,
Feb 2, 2014, 10:09:05 PM2/2/14
to Hotei, golang-nuts
The only safe case is lower case.


On Mon, Feb 3, 2014 at 1:54 PM, Hotei <hote...@gmail.com> wrote:
Seeking clarity on this - would a camelCase package name cause the same issues?  Sounds like it would, but I both camel and upper named packages in a mixed go environment (65% Linux, 30% FreeBSD, 5% Windows7) and have yet to run into any problems.  Several of my utility package names are camelCase and the most frequently used one is upper only.  I'm changing them to increase interoperability, but it it's this big an issue maybe go vet needs to bark about it?  Since it's legal (spec-wise) that may be about all one can hope for. 

I'm also assuming this conventional proscription on mixed case also applies to the import path as well as the package name.  


Cao Nguyên

unread,
Feb 3, 2014, 5:52:56 AM2/3/14
to golan...@googlegroups.com
IMHO, package name in general is the most common thing you type. A lazy guy like me don't like to press 'Shift' too many times. Sound stupid is it!? :D (anyway you have alot of smart responses allready)
Reply all
Reply to author
Forward
0 new messages