In documentation, they use camel case and pascal case both. Is this convention different for functions and methods? Does it decide scope of a function ?
2 Answers
Yes. In Go a field/method is exported if it begins with an upper cased letter while it is unexported if the first letter of the identifier is lower cased. This is similar to the public/private features in most OO languages. Here's an example or two;
package "a"
func ThisFunctionIsExported() {}
func thisOneIsNot() {}
...
package "b"
import "a"
a.ThisFunctionIsExported() // works
a.thisOneIsNot() // compiler error
So, yes the developer is consciously deciding what the scope of those methods are with their casing choice. Lower cased functions are always helper methods inside the package scope, they aren't exposed in importing scopes.

- 46,131
- 16
- 104
- 115
-
This makes sense, because Go is simple and in contrast to Java you don't need to write all the time "public" and "private". – Brain Feb 16 '23 at 07:52
I'm not sure an documentation on Go ever mentions "Pascal case". Supposedly you're using this term to denote camel cased name which begins with either a capital or small letter, right?
Okay, Go uses the term "camel case" for both variations. The distinction between the first letter of an identifier being capital or not does indeed govern the visibility of that symbol. Please read any entry-level guide on Go for more info.

- 51,517
- 14
- 93
- 176
-
Yeah pretty sure he's using pascal case to refer to a name like `thisIsAnObject` while camel case would be `ThisIsAnObject` - not a distinction many developers worry or care about. – evanmcdonnal Sep 22 '16 at 18:43
-