Curriculum Errors & packaging Packages & imports
Packages & imports
Every file declares a package: package foo. Names starting with a capital letter are exported; lowercase are package-private. This rule is mechanical and pervasive; once you internalise it, you stop needing to look at export keywords because there aren't any. Imports go in a single import (...) block.
Exercises
9 ready
01
pick one
Every Go file starts with a package declaration. Pick the
02
pick one
The capitalisation rule is Go's entire export mechanism.
03
pick one
Multi-package imports use the grouped import block form.
04
fill blanks
Type the keyword that declares this file's package. The file
05
fill blanks
Type the keyword that begins the grouped import block. The
06
type one line
The scaffold imports fmt and strings. Write the FULL
07
type one line
Type the call to strings.Repeat that produces abcabcabc
08
write a program
Build a small program demonstrating the package + import +
09
write a program
Theme 5.4 capstone — pull together package, import,