How are packages and imports used in Go?

Answer

Go code is organized into packages — every .go file begins with a package declaration. The main package is special: it defines an executable program with its main() entry point. Other packages are libraries. Import external packages with the import block: import ("fmt" "net/http"). Only identifiers starting with an uppercase letter are exported (public). The Go toolchain enforces that every imported package is actually used — unused imports cause a compile error. Package management is handled by Go modules (go.mod).