Introduction
In the previous section, you completed a basic Go program, which included the following lines of code:
package main
import "fmt"
How do we understand these two lines of code? How do we use the package
and import
statements effectively?
In this lab, you will learn how to create and import packages in Go. This will enable you to organize your code into reusable modules, making your Go projects more maintainable and scalable.
Knowledge Points:
- Definition and declaration of a package
- Understanding exported (public) and unexported (private) identifiers
- Different forms of importing packages: single, grouped, dot, alias, and anonymous imports