CodeVetter · Repo Unpack · Extension points
golang/go
Extension is table-driven almost everywhere: new 'go' subcommands register in main.go's command table; new architectures add an Init func to cmd/compile's archInits map plus an ssagen.ArchInfo; new SSA passes go in the ordered passes table; new VCS tools extend vcsList; experiments are file-pairs in internal/goexperiment; GODEBUGs register in internal/godebugs/table.go; new stdlib API must add lines to api/next and release notes under doc/next; new test/ cases just drop files into the enumerated dirs.
- New 'go' subcommands: create a package under cmd/go/internal/<name>, define a &base.Command{Run, UsageLine, Flag, ...}, and append it to base.Go.Commands in cmd/go/main.go init().
- Nested subcommand groups work via Command.Commands (e.g. 'go mod', 'go work'); Lookup ignores non-runnable entries so help topics coexist in the same table.
- New CPU architecture: add an entry to archInits in cmd/compile/main.go mapping GOARCH name to an Init(*ssagen.ArchInfo), implement the arch package under cmd/compile/internal/<arch>, and add a linker backend dir under cmd/link/internal/<arch>.
- New SSA optimization pass: append to the `passes` table in ssacompile/compile.go (line ~414); ordering is verified ('passes %s and %s out of order') and each pass gets timing/debug plumbing automatically.
- New VCS support: add a *Cmd to vcsList in vcs.go with Name/Cmd/Env/Roots/Scheme/PingCmd/Status; secure schemes come from defaultSecureScheme.
- New toolchain experiment: add exp_<name>_on.go/exp_<name>_off.go file pairs in src/internal/goexperiment (existing pairs: arenas, boringcrypto, cgocheck2, dwarf5, fieldtrack, ...); buildcfg surfaces them via GOEXPERIMENT.
- New GODEBUG compatibility setting: register in internal/godebugs/table.go, document in doc/godebug.md; runtime reads values and fatals on removed ones.
- New stdlib API: implementation in src/<pkg>, one line in api/next/*.txt with proposal issue annotation, release-note entry under doc/next/6-stdlib; the api test enforces the manifest.
- New regression test: drop a .go file with a '// run'/'// errorcheck' comment into test/ or test/fixedbugs; it is picked up automatically by testdir without registration.
- New cmd/go script test: add a txtar script under src/cmd/go/testdata/script; the cmd/internal/script engine interprets commands/conditions without code changes.
- New telemetry counter: call counter.New("name") / counter.Inc in cmd or compiler code; CountFlags auto-instruments flag usage per subcommand.
- Build-time microarch targeting is env-extensible: GOAMD64/GOARM64/GORISCV64 etc. parsed in buildcfg; adding a level means extending the envOr validators, not the tools.
- Vet analysis passes plug in through golang.org/x/tools/go/analysis (imported by work/exec.go), so new analyzers come from the x/tools module rather than this repo.