LESSON · 1 OF 21

What is a package

What is a package

Every Go source file begins with a package clause. It is the first line of real code in the file, and it names the package that the file belongs to:

go
package main

A package is just a folder of Go files that share the same package name. All the files in one folder must declare the same package. The package is Go's unit of code organisation - the way you group related types and functions together.

The shape to remember: one folder is one package, and every file in that folder opens with the same package name line.

Spin up a fresh environment and practice live.
go · fresh machine · ready in under a minute