

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Packages
incomplete
2: Package Naming
incomplete
3: Install
incomplete
4: Modules
incomplete
5: Go Environment
incomplete
6: First Local Program
incomplete
7: Go Run
incomplete
8: Go Build
incomplete
9: Go Install
incomplete
10: Custom Package
incomplete
11: Custom Package Continued
incomplete
12: Remote Packages
incomplete
13: Clean Packages
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
By convention, a package's name is the same as the last element of its import path. For instance, the math/rand package comprises files that begin with:
package rand
That said, package names aren't required to match their import path. For example, I could write a new package with the path github.com/textio/rand and name the package random:
package random
While the above is possible, it is discouraged for the sake of consistency.
A directory of Go code can have at most one package. All .go files in a single directory must all belong to the same package. If they don't, an error will be thrown by the compiler. This is true for main and library packages alike.