Public, Private - Upper Case, Lower Case:

Viewed 47229

New to GoLang, coming from Delphi, C++ :

First time I tried to create my own package in Go, I followed all the instructions about how to lay out the workspace, etc, but I kept on getting a compiler error:

./myPackage.go:52: undefined: myFunc

After poking around a bit I discovered that the public access modifier in Go is achieved simply by declaring a function in upper case. Great.

But when I started experimenting with the container classes - List for starters, I discovered I had to declare a List reference return value like this:

func GetFactors(value *int64) *list.List {...

*list is in lower case.

Same when I declared a local reference to a list - I had to use:

l := list.New()

Again, lower case for list.

So, I'm confused. What is the rule? The list calls and references are obviously public, or I wouldn't be able to call/use them - so why are they in lower case?

3 Answers
Related