# shogo82148/std architecture

> Architecture diagram of the GitHub repository shogo82148/std, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shogo82148/std
- Repository: https://github.com/shogo82148/std

## Overview

#### Purpose and entry points
This is a Go source-tree distribution: standard-library packages, runtime, compiler/toolchain, and developer commands. Primary user-facing executables are `go` (`cmd/go/main.go`), compiler (`cmd/compile/main.go`), linker (`cmd/link/main.go`), assembler (`cmd/asm/main.go`), and bootstrap/build orchestrator (`cmd/dist/main.go`). The root module files, `go.mod` and `go.sum`, establish repository-level module dependencies.

#### Build and command orchestration
`cmd/go` parses user commands and coordinates package loading, module resolution, caching, compilation, linking, testing, formatting, and tool invocation. Its execution engine constructs dependency/action graphs and invokes compiler-family tools.
Paths: `cmd/go/main.go`, `cmd/go/internal/work/action.go`, `cmd/go/internal/work/build.go`.

Module-aware resolution is a boundary between local source/module state and remote repositories, proxies, checksum databases, and VCS clients.
Paths: `cmd/go/internal/modload/load.go`, `cmd/go/internal/modfetch/fetch.go`, `cmd/go/internal/modfetch/sumdb.go`.

#### Compiler pipeline
The Go compiler turns source into object/export data through parsing, IR construction/type checking, lowering and optimization, architecture-specific code generation, then object emission. Compiler-internal packages are deliberately encapsulated under `cmd/compile/internal`.
Paths: `cmd/compile/main.go`, `cmd/compile/internal/noder/irgen.go`, `cmd/compile/internal/ssa/compile.go`.

The shared IR/type boundary separates frontend semantics from optimization and target lowering; SSA has target-specific rewrite/backend implementations for supported architectures.
Paths: `cmd/compile/internal/ir/ir.go`, `cmd/compile/internal/typecheck/typecheck.go`, `cmd/compile/internal/ssagen/ssa.go`.

#### Linking and binary formats
The linker consumes compiler/assembler object inputs, resolves symbols and relocations, performs dead-code elimination, emits debug metadata, and writes platform executables/libraries. It supports ELF, Mach-O, PE, XCOFF, and architecture-specific backends.
Paths: `cmd/link/main.go`, `cmd/link/internal/ld/link.go`, `cmd/link/internal/loader/loader.go`.

Assembly source follows a parallel route through lexical parsing and architecture-specific encoding to object output.
Paths: `cmd/asm/main.go`, `cmd/asm/internal/asm/parse.go`, `cmd/internal/obj/link.go`.

#### Runtime and standard-library boundary
`runtime` implements goroutine scheduling, memory allocation/GC, synchronization, networking pollers, signal handling, profiling, and OS/architecture bindings. It is the execution substrate generated programs depend on.
Paths: `runtime/proc.go`, `runtime/mgc.go`, `runtime/netpoll.go`.

Public packages provide the application-facing API layer, while `internal` contains compiler/runtime/shared implementation contracts not importable by external modules.
Paths: `net/http/server.go`, `crypto/tls/conn.go`, `internal/abi/abi.go`.

#### Platform, native, and security integration
The tree is cross-platform and cross-architecture via build-constrained source variants across runtime, syscall, compiler, and linker. Native integration includes cgo and external C toolchains.
Paths: `cmd/cgo/main.go`, `runtime/cgocall.go`, `syscall/syscall_linux.go`.

External integration is primarily filesystem/process execution, OS syscalls, DNS/networking, Git/SVN/VCS, Go module proxies/checksum services, and optional telemetry. CI is GitHub Actions.
Paths: `cmd/go/internal/vcs/vcs.go`, `cmd/go/internal/telemetrycmd/telemetry.go`, `.github/workflows/sync.yml`.

Main entry points: [`cmd/go/internal/work/action.go`](https://github.com/shogo82148/std/blob/master/cmd/go/internal/work/action.go) (Action graph engine), [`runtime/proc.go`](https://github.com/shogo82148/std/blob/master/runtime/proc.go) (Go runtime), [`cmd/go/internal/modfetch/fetch.go`](https://github.com/shogo82148/std/blob/master/cmd/go/internal/modfetch/fetch.go) (Module fetch & sums), [`cmd/internal/obj/link.go`](https://github.com/shogo82148/std/blob/master/cmd/internal/obj/link.go) (Object representation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commands["Developer Commands"]
  node_go["go command<br/>[main.go]"]
  node_work["Action graph engine<br/>build orchestration<br/>[action.go]"]
  node_modload["Module resolution<br/>module loader<br/>[load.go]"]
  node_modfetch["Module fetch &amp; sums<br/>remote module client<br/>[fetch.go]"]
  node_vcs["VCS integration<br/>repository client<br/>[vcs.go]"]
end

subgraph group_toolchain["Compilation Pipeline"]
  node_compiler["compile<br/>[main.go]"]
  node_frontend["Frontend &amp; type checking<br/>compiler frontend<br/>[irgen.go]"]
  node_ir["IR &amp; type boundary<br/>compiler IR<br/>[ir.go]"]
  node_ssa["SSA optimization &amp; codegen<br/>compiler backend<br/>[compile.go]"]
  node_assembler["asm<br/>assembler command<br/>[main.go]"]
  node_asmparse["Assembly parser<br/>assembly frontend<br/>[parse.go]"]
  node_object["Object representation<br/>object format<br/>[link.go]"]
  node_linker["link<br/>[main.go]"]
  node_linkload["Link loader &amp; emitter<br/>link backend<br/>[link.go]"]
end

subgraph group_platform["Runtime &amp; Platform"]
  node_runtime{{"Go runtime<br/>execution runtime<br/>[proc.go]"}}
  node_cgo["cgo<br/>native interop command<br/>[main.go]"]
end

subgraph group_library["Library Boundaries"]
  node_stdlib["Public standard library<br/>application API<br/>[server.go]"]
  node_abi["Internal ABI<br/>runtime/compiler contract<br/>[abi.go]"]
end

node_remote[("Module proxies &amp; sumdb<br/>external service")]
node_native["OS &amp; C toolchains<br/>native platform"]

node_go -->|"build actions"| node_work
node_go -->|"resolves modules"| node_modload
node_modload -->|"requests dependencies"| node_modfetch
node_modfetch -->|"fetches and verifies"| node_remote
node_modfetch -.->|"falls back to"| node_vcs
node_work -->|"compiles Go"| node_compiler
node_work -->|"assembles sources"| node_assembler
node_work -->|"links outputs"| node_linker
node_compiler -->|"parses and types"| node_frontend
node_frontend -->|"produces typed IR"| node_ir
node_ir -->|"lowered to"| node_ssa
node_ssa -->|"emits objects"| node_object
node_assembler -->|"parses assembly"| node_asmparse
node_asmparse -->|"encodes objects"| node_object
node_object -->|"object inputs"| node_linkload
node_linker -->|"drives"| node_linkload
node_linkload -->|"links runtime"| node_runtime
node_stdlib -->|"executes on"| node_runtime
node_runtime -->|"uses contract"| node_abi
node_cgo -->|"invokes"| node_native
node_runtime -->|"syscalls and native calls"| node_native

click node_go "https://github.com/shogo82148/std/blob/master/cmd/go/main.go"
click node_work "https://github.com/shogo82148/std/blob/master/cmd/go/internal/work/action.go"
click node_modload "https://github.com/shogo82148/std/blob/master/cmd/go/internal/modload/load.go"
click node_modfetch "https://github.com/shogo82148/std/blob/master/cmd/go/internal/modfetch/fetch.go"
click node_vcs "https://github.com/shogo82148/std/blob/master/cmd/go/internal/vcs/vcs.go"
click node_compiler "https://github.com/shogo82148/std/blob/master/cmd/compile/main.go"
click node_frontend "https://github.com/shogo82148/std/blob/master/cmd/compile/internal/noder/irgen.go"
click node_ir "https://github.com/shogo82148/std/blob/master/cmd/compile/internal/ir/ir.go"
click node_ssa "https://github.com/shogo82148/std/blob/master/cmd/compile/internal/ssa/compile.go"
click node_assembler "https://github.com/shogo82148/std/blob/master/cmd/asm/main.go"
click node_asmparse "https://github.com/shogo82148/std/blob/master/cmd/asm/internal/asm/parse.go"
click node_object "https://github.com/shogo82148/std/blob/master/cmd/internal/obj/link.go"
click node_linker "https://github.com/shogo82148/std/blob/master/cmd/link/main.go"
click node_linkload "https://github.com/shogo82148/std/blob/master/cmd/link/internal/ld/link.go"
click node_runtime "https://github.com/shogo82148/std/blob/master/runtime/proc.go"
click node_cgo "https://github.com/shogo82148/std/blob/master/cmd/cgo/main.go"
click node_stdlib "https://github.com/shogo82148/std/blob/master/net/http/server.go"
click node_abi "https://github.com/shogo82148/std/blob/master/internal/abi/abi.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_go,node_work,node_modload,node_modfetch,node_vcs toneBlue
class node_compiler,node_frontend,node_ir,node_ssa,node_assembler,node_asmparse,node_object,node_linker,node_linkload toneAmber
class node_runtime,node_cgo toneMint
class node_stdlib,node_abi toneRose
class node_remote,node_native toneNeutral
```

## Components

### Developer Commands

- [go command](https://github.com/shogo82148/std/blob/master/cmd/go/main.go): command · Builds, tests, formats, and manages packages. · `cmd/go/main.go`
- [Action graph engine](https://github.com/shogo82148/std/blob/master/cmd/go/internal/work/action.go): build orchestration · Constructs dependency actions and invokes tools. · `cmd/go/internal/work/action.go`
- [Module resolution](https://github.com/shogo82148/std/blob/master/cmd/go/internal/modload/load.go): module loader · Resolves local module and package state. · `cmd/go/internal/modload/load.go`
- [Module fetch & sums](https://github.com/shogo82148/std/blob/master/cmd/go/internal/modfetch/fetch.go): remote module client · Fetches modules and verifies checksums. · `cmd/go/internal/modfetch/fetch.go`
- [VCS integration](https://github.com/shogo82148/std/blob/master/cmd/go/internal/vcs/vcs.go): repository client · `cmd/go/internal/vcs/vcs.go`

### Compilation Pipeline

- [compile](https://github.com/shogo82148/std/blob/master/cmd/compile/main.go): compiler command · `cmd/compile/main.go`
- [Frontend & type checking](https://github.com/shogo82148/std/blob/master/cmd/compile/internal/noder/irgen.go): compiler frontend · Parses source and constructs typed IR. · `cmd/compile/internal/noder/irgen.go`
- [IR & type boundary](https://github.com/shogo82148/std/blob/master/cmd/compile/internal/ir/ir.go): compiler IR · `cmd/compile/internal/ir/ir.go`
- [SSA optimization & codegen](https://github.com/shogo82148/std/blob/master/cmd/compile/internal/ssa/compile.go): compiler backend · Optimizes and lowers IR for target architectures. · `cmd/compile/internal/ssa/compile.go`
- [asm](https://github.com/shogo82148/std/blob/master/cmd/asm/main.go): assembler command · `cmd/asm/main.go`
- [Assembly parser](https://github.com/shogo82148/std/blob/master/cmd/asm/internal/asm/parse.go): assembly frontend · `cmd/asm/internal/asm/parse.go`
- [Object representation](https://github.com/shogo82148/std/blob/master/cmd/internal/obj/link.go): object format · Shared object emission contract. · `cmd/internal/obj/link.go`
- [link](https://github.com/shogo82148/std/blob/master/cmd/link/main.go): linker command · `cmd/link/main.go`
- [Link loader & emitter](https://github.com/shogo82148/std/blob/master/cmd/link/internal/ld/link.go): link backend · Resolves symbols and relocations into binaries. · `cmd/link/internal/ld/link.go`

### Runtime & Platform

- [Go runtime](https://github.com/shogo82148/std/blob/master/runtime/proc.go): execution runtime · Provides scheduling, GC, synchronization, and OS bindings. · `runtime/proc.go`
- [cgo](https://github.com/shogo82148/std/blob/master/cmd/cgo/main.go): native interop command · `cmd/cgo/main.go`

### Library Boundaries

- [Public standard library](https://github.com/shogo82148/std/blob/master/net/http/server.go): application API · `net/http/server.go`
- [Internal ABI](https://github.com/shogo82148/std/blob/master/internal/abi/abi.go): runtime/compiler contract · `internal/abi/abi.go`

### Other components

- **Module proxies & sumdb**: external service
- **OS & C toolchains**: native platform

## Connections

- go command → Action graph engine: build actions
- go command → Module resolution: resolves modules
- Module resolution → Module fetch & sums: requests dependencies
- Module fetch & sums → Module proxies & sumdb: fetches and verifies
- Module fetch & sums → VCS integration: falls back to
- Action graph engine → compile: compiles Go
- Action graph engine → asm: assembles sources
- Action graph engine → link: links outputs
- compile → Frontend & type checking: parses and types
- Frontend & type checking → IR & type boundary: produces typed IR
- IR & type boundary → SSA optimization & codegen: lowered to
- SSA optimization & codegen → Object representation: emits objects
- asm → Assembly parser: parses assembly
- Assembly parser → Object representation: encodes objects
- Object representation → Link loader & emitter: object inputs
- link → Link loader & emitter: drives
- Link loader & emitter → Go runtime: links runtime
- Public standard library → Go runtime: executes on
- Go runtime → Internal ABI: uses contract
- cgo → OS & C toolchains: invokes
- Go runtime → OS & C toolchains: syscalls and native calls
