CodeVetter · Repo Unpack · Feature catalog
golang/go
User-facing surface is dominated by the 'go' command: build/install/run/test/list/doc/env/clean/fmt/fix/generate/get/mod/vet/version/work/tool/telemetry/bug plus ~18 help topics. Inside that, the big subsystems are the module system (modload/modfetch/mvs/vcs), the parallel action-graph build engine with content-hash caching (work.Builder), cgo/SWIG foreign-function builds, coverage instrumentation, PGO, FIPS-140 crypto mode, toolchain auto-switching, and opt-in telemetry. Separate binaries ship gofmt, vet, pprof, trace, cover, covdata, test2json, asm, link, compile, cgo, nm, objdump, pack, addr2line, buildid, dist, distpack, preprofile, relnote.
- go subcommands registered in main.go init(): bug, build, clean, doc, env, fix, fmt, generate, get, install, list, mod, run, telemetry, test, tool, version, vet, work — plus help topics (buildconstraint, buildjson, buildmode, c, cache, environment, filetype, goauth, gopath, goproxy, importpath, module-auth, modules, packages, private, testflag, testfunc, vcs).
- 'go mod' has subcommands download, edit, graph, init, tidy, vendor, verify, why (one file each under cmd/go/internal/modcmd); 'go work' has edit, init, sync, use, vendor.
- GOTOOLCHAIN auto-switching: toolchain.Select() runs early in main, reads go.mod/go.work toolchain lines, downloads golang.org/toolchain v0.0.1-<version>.<goos>-<goarch> modules and re-execs the target binary, bounded by maxSwitch=100 loop detection via GOTOOLCHAIN_INTERNAL_SWITCH_COUNT.
- The build engine work.Builder.Do executes a depth-first-prioritized action DAG with content-hash caching (buildActionID via sha256), trimming the default build cache on completion.
- cgo support: exec.go contains runCgo, processCgoOutputs, dynimport, swig/swigOne/swigVersionCheck, and C compiler invocation helpers (gcc, gxx, gfortran, gccld, PkgconfigCmd) honoring CGO flags and pkg-config.
- Coverage: runCover/cover/writeCoverPkgInputs instrument packages during 'go test -cover'/'go build -cover', producing covmeta files consumed by cmd/cover and cmd/covdata.
- Vet is wired into 'go test': buildVetConfig/vet actions run analysis passes (golang.org/x/tools/go/analysis) as part of the test action graph.
- PGO: compiler flag -pgo loads a profile via pgoir.New in gc.Main, feeding weighted call graphs into interleaved.DevirtualizeAndInlinePackage.
- FIPS 140 support: GOFIPS140 env var validated in buildcfg (off/latest/inprocess/certified/v1.Y.Z), fips140 package in cmd/go, crypto implementation under src/crypto/internal/fips140 with GOFIPS140 zip shipping in the distribution.
- Telemetry: opt-in counters via cmd/internal/telemetry/counter (counter.Open, counter.Inc, CountFlags) throughout main.go and the compiler, managed by 'go telemetry' and a sidecar child/parent upload model (telemetry.MaybeChild/MaybeParent).
- 'go generate' scans //go:generate directives; test flag defs are generated: cmd/go/internal/test/genflags.go generates flagdefs.go shared between go test and vet.
- Standalone tools shipped under src/cmd: asm, cgo, compile, link, gofmt, vet, pprof, trace, cover, covdata, test2json, nm, objdump, pack, addr2line, buildid, fix, api, dist, distpack, export, preprofile, relnote.
- The stdlib itself is a feature surface of ~150 packages under src/ including net/http, crypto/tls, os/exec, plugin, embed, testing, runtime/trace, and newer ones like simd, weak, unique, arena, structs, uuid.
- Runtime GODEBUG compatibility settings are user-facing knobs documented in doc/godebug.md and registered in internal/godebugs/table.go; removed settings cause a fatal at startup.