Naming conventions: Difference between revisions

Content added Content deleted
(Added Go)
(→‎{{header|Go}}: Reworded point 3 which wasn't entirely accurate previously.)
Line 551: Line 551:
2. Names of all other entities should be either 'mixedCaps' or 'MixedCaps' (no underscores).
2. Names of all other entities should be either 'mixedCaps' or 'MixedCaps' (no underscores).


3. Names which are private to a package must begin with a lower case letter and names which are exported must begin with an upper case letter. This is not a convention, it is an obligatory part of the language.
3. Names which are exported from a package (i.e. public names) must begin with an upper case letter and be declared either at 'top level' within the package or be field or method names. All other names are not exported and hence are private to the package. This is not a convention, it is an obligatory part of the language.


4. If a struct has a private field, 'owner' say, public access to which is via by a getter and/or setter method, then the former should use the style Owner() and the latter SetOwner().
4. If a struct has a private field, 'owner' say, public access to which is via by a getter and/or setter method, then the former should use the style Owner() and the latter SetOwner().