Packages and Modules
Modules, packages, and import rules. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not.
Search across all documentation pages
Modules, packages, and import rules. Results appear in the same fence: same-line // comments when short, multiline // blocks below the sample when not.
Binaries start at package main and func main.
// package main
// func main() { ... }Uppercase identifiers are exported.
// Foo is public; foo is package-private
type Foo struct{}
// type foo struct{}Module path and Go version.
// module example.com/app
// go 1.26Rename imports to avoid clashes.
import (
crand "crypto/rand"
)
// crand.Readerinternal/ is importable only by parent tree.
// module/internal/secret is private to module/...Side-effect import.
// import _ "image/png"
// registers PNG decoderAdd/update dependencies.
// go get example.com/mod@v1.2.3
// go get example.com/mod@latestMulti-module workspaces.
// go work init ./svc ./lib
// go.work use directivesLocal replace for development.
// replace example.com/lib => ../libimport . "pkg" pollutes - avoid in apps.
// prefer explicit package namesPackage-level vars then init funcs.
// var x = f()
// func init() { ... }//go:embed for static assets.
// //go:embed static/*
// var static embed.FSConditional files.
// //go:build linux
// // +build linuxQuery packages/modules.
// go list -m all
// go list ./...Optional vendoring.
// go mod vendor
// go build -mod=vendorStack versions: Go 1.26.x · chi/gin/echo latest (verify at build)
Reviewed by Chris St. John·Last updated Jul 18, 2026