Camp 1 · Step 3 of 12
Packages and func main
How Go organizes code — packages, imports, and the capitalization rule that replaces public/private.
Go has no public or private keywords, no header files, no elaborate
module ceremony. It has packages and one delightful trick.
Packages: folders of shared purpose
Every Go file starts with a package declaration; files in one directory share one package. The standard library is a treasury of them:
The grouped import ( ... ) form pulls in several packages. You call
into a package as packagename.Function.
The capitalization rule
Here's Go's famous trick — the first letter decides visibility:
strings.ToUpper— Capitalized = exported (usable from other packages)strings.toLower(imagine) — lowercase = unexported (package-private)
No keywords. You can read any Go code and instantly know what's public
API and what's internal: just look at the case. This is why it's
fmt.Println, not fmt.println.
Where main fits
An executable needs exactly two things: package main and func main().
The := you spotted above declares-and-assigns in one stroke — Go infers
the type. It's the workhorse of Go code, and next camp dives into it
properly.
In Go, what makes a function usable from other packages?
Which pair makes a Go program executable?