# Data flow — golang/go

> Canonical page: https://codevetter.com/unpack/go/data-flow

# Data flow — golang/go

Scanned commit 12c76d447f576e6c14c566c8524c13a0c0d476b9 (2026-09-22). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

End-to-end: user args → cmd/go/main → toolchain.Select (may re-exec a downloaded toolchain) → load.Package resolution via go.mod/go.work → modload computes the build list with MVS, fetching modules through modfetch (GOPROXY → zip → sumdb/go.sum verify → modcache) or vcs direct → work.Builder builds an action DAG (compile/cgo/cover/vet/link actions) keyed by sha256 action IDs against the build cache → cmd/compile turns source through noder/typecheck/inline/escape/walk into SSA and object files → cmd/link consumes objects+importcfg and emits the binary. At runtime, compiled binaries start in runtime.main which enables GC and runs init tasks before main.main.
- Package loading produces load.Package structs; PackagePublic fields are declared part of the go command's public API for 'go list -json' and must stay in sync with list.go. — [src/cmd/go/internal/load/pkg.go#L57-80](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/load/pkg.go#L57-L80)
- Module graph resolution: modload.Init loads go.mod/go.work, LoadPackages resolves import patterns to modules; the toolchain module itself is special-cased (ErrToolchain on Download). — [src/cmd/go/internal/modload/init.go#L524](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/modload/init.go#L524) [src/cmd/go/internal/modload/load.go#L245](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/modload/load.go#L245) [src/cmd/go/internal/modfetch/fetch.go#L38-71](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/modfetch/fetch.go#L38-L71)
- Module fetch path: Fetcher.Download → downloadCache.Do (dedup) → download → checkMod verifies against go.sum and the checksum database → unzip into GOMODCACHE; a TooNewError is raised if the module's go directive exceeds the local toolchain. — [src/cmd/go/internal/modfetch/fetch.go#L40-110](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/modfetch/fetch.go#L40-L110)
- Non-proxy resolution goes through cmd/go/internal/vcs: vcsList = [hg, git, svn, fossil], each a Cmd describing binary name, schemes, root-detection; IsSecure gates insecure schemes (https/git+ssh/svn+ssh/ssh allowed; GIT_ALLOW_PROTOCOL overrides for git). — [src/cmd/go/internal/vcs/vcs.go#L35-140](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/vcs/vcs.go#L35-L140)
- Build action graph: Builder.Do assigns DFS post-order priorities, each action's cache key is buildActionID hashing inputs/flags/toolchain IDs; cache hits short-circuit compile steps; cgo, cover, vet, link are distinct action types. — [src/cmd/go/internal/work/exec.go#L76-120](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/work/exec.go#L76-L120) [src/cmd/go/internal/work/exec.go#L265-390](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/work/exec.go#L265-L390)
- Compiler pipeline in gc.Main: noder.LoadPackage (parse+typecheck via types2 machinery) → bloop markings → interleaved.DevirtualizeAndInlinePackage (with optional PGO profile) → loopvar capture fixes → pkginit.MakeTask → escape.Funcs → rewriteresults/slice transforms → enqueueFunc→compileFunctions→SSA backend → dumpobj writes the object file. — [src/cmd/compile/internal/gc/main.go#L218-400](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/compile/internal/gc/main.go#L218-L400)
- The SSA backend pass list is a static ordered table `passes` in ssacompile/compile.go run by ssa.Compile; phases are checked for ordering violations and support per-pass debug flags via -d=ssa/... — [src/cmd/compile/internal/ssacompile/compile.go#L413-480](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/compile/internal/ssacompile/compile.go#L413-L480) [src/cmd/compile/internal/ssacompile/compile.go#L66-90](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/compile/internal/ssacompile/compile.go#L66-L90)
- Link flow: Builder.link writes an importcfg (writeLinkImportcfg), invokes cmd/link which loads goobj objects via cmd/internal/goobj, performs deadcode elimination/address layout, and stamps a buildid; external link mode delegates to extld. — [src/cmd/go/internal/work/exec.go#L2104-2168](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/work/exec.go#L2104-L2168) [src/cmd/link/internal/ld/main.go#L57-120](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/link/internal/ld/main.go#L57-L120) [src/cmd/internal/goobj](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/internal/goobj)
- Runtime startup data flow: runtime.main (on g0/m0) → doInit(runtime_inittasks) → gcenable() → doInit over each moduledata's inittasks (linker-computed init graph) → close(mainInitDoneChan) → main_main() i.e. user's main. — [src/runtime/proc.go#L153-290](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/runtime/proc.go#L153-L290)
- Goroutine lifecycle: newproc/newproc1 creates a g, runqput places it on a P run queue or runnext, wakep may unpark an M; schedule→findRunnable→execute→gogo runs it; timers and netpoll feed the same queues. — [src/runtime/proc.go#L5335-5353](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/runtime/proc.go#L5335-L5353) [src/runtime/proc.go#L4151-4247](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/runtime/proc.go#L4151-L4247)
- GC cycle data flow: sweep termination STW → concurrent mark with write barrier shading and mutator assists → distributed termination detection (gcMarkDone) → mark termination STW → concurrent sweep; heap goal driven by GOGC. — [src/runtime/mgc.go#L24-118](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/runtime/mgc.go#L24-L118)
- go test data flow: runTest → builderTest constructs buildAction/runAction/printAction triples; a generated testmain binary runs and its output is piped through test2json for -json reporting. — [src/cmd/go/internal/test/test.go#L694](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/test/test.go#L694) [src/cmd/go/internal/test/test.go#L1143](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/internal/test/test.go#L1143) [src/cmd/test2json](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/test2json)
- Telemetry data flow: counters are written to a counter file opened at startup (skipped for 'go telemetry off'); MaybeParent spawns the upload sidecar; CountFlags records flag usage patterns. — [src/cmd/go/main.go#L98-114](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/main.go#L98-L114) [src/cmd/go/main.go#L223-256](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/go/main.go#L223-L256)
- API check data flow: cmd/api tests walk each stdlib package's exported API via go/ast and compare against golden lines in api/go1*.txt + api/next, with per-feature proposal issue annotations required since go1.19. — [api/README](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/api/README) [src/cmd/api/api_test.go#L36-101](https://github.com/golang/go/blob/12c76d447f576e6c14c566c8524c13a0c0d476b9/src/cmd/api/api_test.go#L36-L101)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
