# goinaction/code architecture

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

- Interactive diagram: https://gitdiagram.com/goinaction/code
- Repository: https://github.com/goinaction/code

## Overview

This repository is a collection of independent Go examples from *Go in Action*, not one integrated application. Its examples demonstrate language and package boundaries, I/O and database access, concurrency patterns, HTTP handling, and interface-based design. The graph groups representative examples by chapter topic; explicit edges show only relationships visible in excerpts or SOURCE INDEX references. Many listing files are independent examples whose specific behavior is not established by the available excerpts, so they are represented without inferred connections.

Main entry points: [`chapter3/wordcount/wordcount.go`](https://github.com/goinaction/code/blob/master/chapter3/wordcount/wordcount.go) (Word counter), [`chapter3/dbdriver/main.go`](https://github.com/goinaction/code/blob/master/chapter3/dbdriver/main.go) (SQL example), [`chapter7/patterns/pool/main/main.go`](https://github.com/goinaction/code/blob/master/chapter7/patterns/pool/main/main.go) (Pool example), [`chapter7/patterns/runner/main/main.go`](https://github.com/goinaction/code/blob/master/chapter7/patterns/runner/main/main.go) (Runner example)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_io["I/O and databases"]
  node_wordcount["Word counter<br/>[wordcount.go]"]
  node_words["Word counting<br/>[count.go]"]
  node_dbexample["SQL example<br/>[main.go]"]
  node_postgres["Postgres driver<br/>[postgres.go]"]
end

subgraph group_language["Language and packages"]
  node_listing11["Listing 11<br/>[listing11.go]"]
  node_listing34["Listing 34<br/>[listing34.go]"]
  node_listing36["Listing 36<br/>[listing36.go]"]
  node_listing48["Listing 48<br/>[listing48.go]"]
  node_listing56["Listing 56<br/>[listing56.go]"]
  node_listing60["Listing 60<br/>[listing60.go]"]
  node_listing01["Listing 01<br/>[listing01.go]"]
  node_listing04["Listing 04<br/>[listing04.go]"]
  node_listing07["Listing 07<br/>[listing07.go]"]
  node_listing09["Listing 09<br/>[listing09.go]"]
  node_listing13["Listing 13<br/>[listing13.go]"]
  node_listing15["Listing 15<br/>[listing15.go]"]
  node_listing16["Listing 16<br/>[listing16.go]"]
  node_listing20["Listing 20<br/>[listing20.go]"]
  node_listing22["Listing 22<br/>[listing22.go]"]
  node_listing24["Listing 24<br/>[listing24.go]"]
end

subgraph group_concurrency["Concurrency patterns"]
  node_pooldemo["Pool example<br/>[main.go]"]
  node_pool["Resource pool<br/>[pool.go]"]
  node_runnerdemo["Runner example<br/>[main.go]"]
  node_runner["Task runner<br/>[runner.go]"]
  node_searchdemo["Search example<br/>[main.go]"]
  node_search["Concurrent search<br/>[search.go]"]
  node_searchers["Search providers<br/>[searchers.go]"]
  node_semaphore["Semaphore example<br/>[semaphore.go]"]
  node_workdemo["Work example<br/>[main.go]"]
  node_work["Work pool<br/>[work.go]"]
  node_listing11c8["Listing 11<br/>[listing11.go]"]
  node_listing24c8["Listing 24<br/>[listing24.go]"]
  node_listing27["Listing 27<br/>[listing27.go]"]
  node_listing29["Listing 29<br/>[listing29.go]"]
end

subgraph group_web["HTTP example"]
end

subgraph group_interfaces["Interfaces and design"]
end

node_wordcount -->|"counts words"| node_words
node_dbexample -->|"registers driver"| node_postgres
node_pooldemo -->|"acquires resources"| node_pool
node_runnerdemo -->|"runs tasks"| node_runner
node_searchdemo -->|"submits searches"| node_search
node_workdemo -->|"submits work"| node_work

click node_wordcount "https://github.com/goinaction/code/blob/master/chapter3/wordcount/wordcount.go"
click node_words "https://github.com/goinaction/code/blob/master/chapter3/words/count.go"
click node_dbexample "https://github.com/goinaction/code/blob/master/chapter3/dbdriver/main.go"
click node_postgres "https://github.com/goinaction/code/blob/master/chapter3/dbdriver/postgres/postgres.go"
click node_listing11 "https://github.com/goinaction/code/blob/master/chapter5/listing11/listing11.go"
click node_listing34 "https://github.com/goinaction/code/blob/master/chapter5/listing34/listing34.go"
click node_listing36 "https://github.com/goinaction/code/blob/master/chapter5/listing36/listing36.go"
click node_listing48 "https://github.com/goinaction/code/blob/master/chapter5/listing48/listing48.go"
click node_listing56 "https://github.com/goinaction/code/blob/master/chapter5/listing56/listing56.go"
click node_listing60 "https://github.com/goinaction/code/blob/master/chapter5/listing60/listing60.go"
click node_listing01 "https://github.com/goinaction/code/blob/master/chapter6/listing01/listing01.go"
click node_listing04 "https://github.com/goinaction/code/blob/master/chapter6/listing04/listing04.go"
click node_listing07 "https://github.com/goinaction/code/blob/master/chapter6/listing07/listing07.go"
click node_listing09 "https://github.com/goinaction/code/blob/master/chapter6/listing09/listing09.go"
click node_listing13 "https://github.com/goinaction/code/blob/master/chapter6/listing13/listing13.go"
click node_listing15 "https://github.com/goinaction/code/blob/master/chapter6/listing15/listing15.go"
click node_listing16 "https://github.com/goinaction/code/blob/master/chapter6/listing16/listing16.go"
click node_listing20 "https://github.com/goinaction/code/blob/master/chapter6/listing20/listing20.go"
click node_listing22 "https://github.com/goinaction/code/blob/master/chapter6/listing22/listing22.go"
click node_listing24 "https://github.com/goinaction/code/blob/master/chapter6/listing24/listing24.go"
click node_pooldemo "https://github.com/goinaction/code/blob/master/chapter7/patterns/pool/main/main.go"
click node_pool "https://github.com/goinaction/code/blob/master/chapter7/patterns/pool/pool.go"
click node_runnerdemo "https://github.com/goinaction/code/blob/master/chapter7/patterns/runner/main/main.go"
click node_runner "https://github.com/goinaction/code/blob/master/chapter7/patterns/runner/runner.go"
click node_searchdemo "https://github.com/goinaction/code/blob/master/chapter7/patterns/search/main/main.go"
click node_search "https://github.com/goinaction/code/blob/master/chapter7/patterns/search/search.go"
click node_searchers "https://github.com/goinaction/code/blob/master/chapter7/patterns/search/searchers.go"
click node_semaphore "https://github.com/goinaction/code/blob/master/chapter7/patterns/semaphore/semaphore.go"
click node_workdemo "https://github.com/goinaction/code/blob/master/chapter7/patterns/work/main/main.go"
click node_work "https://github.com/goinaction/code/blob/master/chapter7/patterns/work/work.go"
click node_listing11c8 "https://github.com/goinaction/code/blob/master/chapter8/listing11/listing11.go"
click node_listing24c8 "https://github.com/goinaction/code/blob/master/chapter8/listing24/listing24.go"
click node_listing27 "https://github.com/goinaction/code/blob/master/chapter8/listing27/listing27.go"
click node_listing29 "https://github.com/goinaction/code/blob/master/chapter8/listing29/listing29.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_wordcount,node_words,node_dbexample,node_postgres toneBlue
class node_listing11,node_listing34,node_listing36,node_listing48,node_listing56,node_listing60,node_listing01,node_listing04,node_listing07,node_listing09,node_listing13,node_listing15,node_listing16,node_listing20,node_listing22,node_listing24 toneAmber
class node_pooldemo,node_pool,node_runnerdemo,node_runner,node_searchdemo,node_search,node_searchers,node_semaphore,node_workdemo,node_work,node_listing11c8,node_listing24c8,node_listing27,node_listing29 toneMint
```

## Components

### I/O and databases

- [Word counter](https://github.com/goinaction/code/blob/master/chapter3/wordcount/wordcount.go): `chapter3/wordcount/wordcount.go`
- [Word counting](https://github.com/goinaction/code/blob/master/chapter3/words/count.go): `chapter3/words/count.go`
- [SQL example](https://github.com/goinaction/code/blob/master/chapter3/dbdriver/main.go): `chapter3/dbdriver/main.go`
- [Postgres driver](https://github.com/goinaction/code/blob/master/chapter3/dbdriver/postgres/postgres.go): `chapter3/dbdriver/postgres/postgres.go`

### Language and packages

- [Listing 11](https://github.com/goinaction/code/blob/master/chapter5/listing11/listing11.go): `chapter5/listing11/listing11.go`
- [Listing 34](https://github.com/goinaction/code/blob/master/chapter5/listing34/listing34.go): `chapter5/listing34/listing34.go`
- [Listing 36](https://github.com/goinaction/code/blob/master/chapter5/listing36/listing36.go): `chapter5/listing36/listing36.go`
- [Listing 48](https://github.com/goinaction/code/blob/master/chapter5/listing48/listing48.go): `chapter5/listing48/listing48.go`
- [Listing 56](https://github.com/goinaction/code/blob/master/chapter5/listing56/listing56.go): `chapter5/listing56/listing56.go`
- [Listing 60](https://github.com/goinaction/code/blob/master/chapter5/listing60/listing60.go): `chapter5/listing60/listing60.go`
- [Listing 01](https://github.com/goinaction/code/blob/master/chapter6/listing01/listing01.go): `chapter6/listing01/listing01.go`
- [Listing 04](https://github.com/goinaction/code/blob/master/chapter6/listing04/listing04.go): `chapter6/listing04/listing04.go`
- [Listing 07](https://github.com/goinaction/code/blob/master/chapter6/listing07/listing07.go): `chapter6/listing07/listing07.go`
- [Listing 09](https://github.com/goinaction/code/blob/master/chapter6/listing09/listing09.go): `chapter6/listing09/listing09.go`
- [Listing 13](https://github.com/goinaction/code/blob/master/chapter6/listing13/listing13.go): `chapter6/listing13/listing13.go`
- [Listing 15](https://github.com/goinaction/code/blob/master/chapter6/listing15/listing15.go): `chapter6/listing15/listing15.go`
- [Listing 16](https://github.com/goinaction/code/blob/master/chapter6/listing16/listing16.go): `chapter6/listing16/listing16.go`
- [Listing 20](https://github.com/goinaction/code/blob/master/chapter6/listing20/listing20.go): `chapter6/listing20/listing20.go`
- [Listing 22](https://github.com/goinaction/code/blob/master/chapter6/listing22/listing22.go): `chapter6/listing22/listing22.go`
- [Listing 24](https://github.com/goinaction/code/blob/master/chapter6/listing24/listing24.go): `chapter6/listing24/listing24.go`

### Concurrency patterns

- [Pool example](https://github.com/goinaction/code/blob/master/chapter7/patterns/pool/main/main.go): `chapter7/patterns/pool/main/main.go`
- [Resource pool](https://github.com/goinaction/code/blob/master/chapter7/patterns/pool/pool.go): `chapter7/patterns/pool/pool.go`
- [Runner example](https://github.com/goinaction/code/blob/master/chapter7/patterns/runner/main/main.go): `chapter7/patterns/runner/main/main.go`
- [Task runner](https://github.com/goinaction/code/blob/master/chapter7/patterns/runner/runner.go): `chapter7/patterns/runner/runner.go`
- [Search example](https://github.com/goinaction/code/blob/master/chapter7/patterns/search/main/main.go): `chapter7/patterns/search/main/main.go`
- [Concurrent search](https://github.com/goinaction/code/blob/master/chapter7/patterns/search/search.go): `chapter7/patterns/search/search.go`
- [Search providers](https://github.com/goinaction/code/blob/master/chapter7/patterns/search/searchers.go): `chapter7/patterns/search/searchers.go`
- [Semaphore example](https://github.com/goinaction/code/blob/master/chapter7/patterns/semaphore/semaphore.go): `chapter7/patterns/semaphore/semaphore.go`
- [Work example](https://github.com/goinaction/code/blob/master/chapter7/patterns/work/main/main.go): `chapter7/patterns/work/main/main.go`
- [Work pool](https://github.com/goinaction/code/blob/master/chapter7/patterns/work/work.go): `chapter7/patterns/work/work.go`
- [Listing 11](https://github.com/goinaction/code/blob/master/chapter8/listing11/listing11.go): `chapter8/listing11/listing11.go`
- [Listing 24](https://github.com/goinaction/code/blob/master/chapter8/listing24/listing24.go): `chapter8/listing24/listing24.go`
- [Listing 27](https://github.com/goinaction/code/blob/master/chapter8/listing27/listing27.go): `chapter8/listing27/listing27.go`
- [Listing 29](https://github.com/goinaction/code/blob/master/chapter8/listing29/listing29.go): `chapter8/listing29/listing29.go`

## Connections

- Word counter → Word counting: counts words (evidence: `chapter3/wordcount/wordcount.go`)
- SQL example → Postgres driver: registers driver (evidence: `chapter3/dbdriver/main.go`)
- Pool example → Resource pool: acquires resources (evidence: `chapter7/patterns/pool/main/main.go`)
- Runner example → Task runner: runs tasks (evidence: `chapter7/patterns/runner/main/main.go`)
- Search example → Concurrent search: submits searches (evidence: `chapter7/patterns/search/main/main.go`)
- Work example → Work pool: submits work (evidence: `chapter7/patterns/work/main/main.go`)
