API Compatibility Checker
Purpose and Scope
The API compatibility checker is best understood as a release-readiness gate for the public Go distribution. Its job is to keep the exported surface of the standard library and shipped tools intentional as Go evolves. The repository README establishes the surrounding context: this is the source for the Go programming language, the canonical repository is hosted on the Go project infrastructure, the GitHub repository is a mirror, releases are obtained as official binary distributions, and contributions are expected to follow the project contribution process. That framing matters because compatibility review protects users of those public releases, not only developers building from a local checkout.
Sources: README.md
For contributors, compatibility review sits between local implementation work and the point where a change becomes part of a release. A change may add a public name, alter behavior reachable through a public command, or expose a new target-specific execution path. The checker workflow is meant to make those changes explicit, connect them to proposal or issue discussion when required, and prevent accidental API drift. The official module release workflow describes releases as a deliberate sequence of preparation, testing, and version signaling; the Go tree applies the same discipline to its own distribution by making public surface changes reviewable artifacts rather than incidental build byproducts.
Sources: README.md
Relevant Source Files
- README.md — Defines the repository identity, canonical location, binary and source installation entry points, licensing, and contribution guidance that frame compatibility work as part of the public Go project.
- misc/go_android_exec/main.go — Shows a target-specific execution wrapper used by the Go tool for Android testing, illustrating that compatibility validation must account for supported operating-system and architecture combinations.
- src/cmd/addr2line/main.go — Defines a small shipped tool interface, including usage, input, output, telemetry counters, and an explicit warning that it is intended only for pprof and may change.
- src/cmd/asm/main.go — Shows the assembler command entry point, architecture selection, flag parsing, object-file creation, and error behavior for a toolchain command with a stable operational role.
- src/cmd/cgo/main.go — Defines cgo’s package-level data structures for translating Go references to C names, demonstrating a substantial command surface tied to build behavior and generated files.
- src/cmd/compile/internal/gc/main.go — Defines the compiler main pipeline from flags and source parsing through type checking, compilation, and package output, grounding compatibility review in the core toolchain.
System-to-Code Mapping
The source files in this page show that Go compatibility is not a single package concern. The public distribution includes documentation, a compiler, assembler, cgo integration, helper tools, and platform execution support. The README gives the user-facing boundary: Go is downloaded, installed, and contributed to through documented project channels. The command files show executable boundaries: each command accepts flags or arguments, reports errors, and produces observable output. An API checker workflow must therefore distinguish between exported language and library APIs, stable tool behavior, and internal implementation details that can change without compatibility promises.
Sources: README.md, src/cmd/addr2line/main.go, src/cmd/asm/main.go, src/cmd/cgo/main.go, src/cmd/compile/internal/gc/main.go
The clearest example of a deliberately narrow compatibility promise is the address-to-line tool. Its source documents the invocation shape as a tool run with a binary argument, input as hexadecimal addresses on standard input, and output as two lines for each address: a function name followed by a file and line. The same comment states that the tool is intended only for pprof and that its interface may change or be deleted. A compatibility reviewer should preserve that distinction: not every shipped executable has the same public contract, and source comments can narrow what the release must guarantee.
Sources: src/cmd/addr2line/main.go
The assembler has a broader toolchain role. Its entry point checks build configuration, parses command flags, selects an architecture from the current target, initializes an object-linking context, parses input assembly files, and writes an object file. The main routine also handles target and security-related flags, including shared linking and spectre settings, and removes the output file when assembly fails. Those observable behaviors help reviewers decide whether a change is merely an implementation refactor or whether it changes command semantics that builders, tests, and downstream tooling may rely on.
Sources: src/cmd/asm/main.go
The cgo entry point demonstrates another compatibility category: generated-code contracts. Its package and file structures collect parsed Go files, C preambles, references to expressions in package C, calls, exported functions, gcc options, linker flags, no-callback directives, and no-escape directives. Even though many details are implementation structures, they represent how command behavior is assembled from source analysis and C compiler interaction. When cgo changes, compatibility review should consider both Go source accepted by the tool and generated artifacts consumed by the rest of the build.
Sources: src/cmd/cgo/main.go
Compatibility Review Workflow
A practical review starts by identifying the public boundary affected by the change. For a standard library API change, that boundary is normally exported identifiers and documented behavior. For a command change, it may be invocation syntax, flags, environment variables, output format, generated files, exit behavior, or documented limitations. The supplied command sources make those categories visible: addr2line has a compact documented interface, asm maps flags into object output, cgo transforms source into generated Go and C glue, and the compiler coordinates the primary source-to-object pipeline.
Sources: src/cmd/addr2line/main.go, src/cmd/asm/main.go, src/cmd/cgo/main.go, src/cmd/compile/internal/gc/main.go
Next, connect the change to the project process. The README directs contributors to the Go contribution guidelines and says the issue tracker is used for bug reports and proposals. That is important for API compatibility because public API additions and incompatible changes need a visible rationale. A reviewer should be able to answer three questions before accepting the compatibility data update: what public surface changed, why the change is intended, and which issue, proposal, or release-note discussion explains the decision. The API data file should be treated as a record of that decision, not as a substitute for it.
Sources: README.md
Then compare implementation behavior with declared compatibility data. If a command starts accepting a new option, producing a new documented output form, or exposing a new supported platform path, tests and API records should agree with the implementation. The Android execution wrapper is a useful reminder that the Go distribution is multi-platform. It serializes adb commands with a file lock, waits for a boot-completed device, copies the Go root to the device, and constructs temporary package execution directories. Platform support can therefore affect whether a change is truly portable and release-ready.
Sources: misc/go_android_exec/main.go
Finally, run the relevant validation path before review. For compiler and command changes, that usually means exercising the command through the Go test infrastructure rather than only unit-testing a helper function. The compiler main routine initializes architecture-specific state, parses flags, configures package state, handles special pseudo-packages, and uses panic handling to report internal compiler errors. A compatibility check that ignores the actual command path can miss interactions among flags, target configuration, telemetry setup, and output generation. Reviewers should prefer evidence from the path users and builders actually execute.
Sources: src/cmd/compile/internal/gc/main.go
Data and Reference Notes
Compatibility data should be small, explicit, and reviewable. For public API additions, each record should correspond to a concrete exported name or observable public contract rather than a broad implementation area. For command behavior, record the stable promise only when the command is intended to make one. The addr2line source shows why this distinction matters: it documents a usage form and pprof-oriented behavior while also warning that the interface is not a general promise. That kind of source-level statement should guide whether a change belongs in compatibility data, release notes, tests, or only implementation review.
Sources: src/cmd/addr2line/main.go
Use the following reviewer checklist when preparing an API compatibility update. First, identify the public package, command, flag, generated artifact, or platform path affected. Second, confirm whether the change is an addition, a behavioral correction, a removal, or an internal refactor. Third, link the change to the appropriate issue or proposal discussion when the README contribution process implies project-level review. Fourth, update tests that exercise the actual command or package path. Fifth, keep release-facing text consistent with the compatibility data so users can understand the change when they install the next distribution.
Sources: README.md, src/cmd/addr2line/main.go, src/cmd/asm/main.go, src/cmd/cgo/main.go, src/cmd/compile/internal/gc/main.go
Edge Cases and Next Steps
Two common edge cases deserve special attention. The first is a tool that is shipped but intentionally scoped to another tool, such as addr2line being present for pprof rather than as a general compatibility promise. The second is a platform-specific helper, such as the Android executor, whose behavior is critical in builders and tests but not a user-facing standard library API. In both cases, the compatibility reviewer should avoid over-promising while still ensuring that changes are tested, justified, and visible to the maintainers responsible for releases.
Sources: misc/go_android_exec/main.go, src/cmd/addr2line/main.go
For the next step, read this page together with release and toolchain documentation. Start with the overview and release-notes process pages to understand how public changes are communicated, then use the toolchain command reference for command-specific contracts. When reviewing a concrete change, inspect the implementation entry point, the tests that exercise it, and the compatibility data update in the same review. That combined view keeps the Go project’s public promise aligned with the source tree that produces the release.
Sources: README.md, src/cmd/asm/main.go, src/cmd/cgo/main.go, src/cmd/compile/internal/gc/main.go