HiveBrain v1.2.0
Get Started
← Back to all entries
patterngoCritical

Go naming conventions for const

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
namingconventionsconstfor

Problem

I'm trying to determine whether there is a naming convention for the names of const in Golang.

I personally would tend to follow the C style and write them in upper case, but I haven't found anything on this page http://golang.org/doc/effective_go.html which seems to list some naming conventions for the language.

Solution

The standard library uses camel-case, so I advise you do that as well. The first letter is uppercase or lowercase depending on whether you want to export the constant.

A few examples:

  • md5.BlockSize



  • os.O_RDONLY is an exception because it was borrowed directly from POSIX.



  • os.PathSeparator

Context

Stack Overflow Q#22688906, score: 240

Revisions (0)

No revisions yet.