# vivekvashist/if-err-nil architecture

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

- Interactive diagram: https://gitdiagram.com/vivekvashist/if-err-nil
- Repository: https://github.com/vivekvashist/if-err-nil

## Overview

1. This repository is not a single application; it is a Go learning sandbox made of many small, independent programs. The root README explicitly says it is a personal sandbox for learning Go.

2. The dominant architectural boundary is directory-level isolation. Almost every top-level folder contains its own `main.go`, which means each folder is a separate executable entry point rather than a shared library or microservice.

3. There is no central runtime, server, or orchestration layer. The repository is organized as a set of standalone examples that you run individually with the Go toolchain, usually producing console output.

4. The folders appear to correspond to isolated language-topic exercises:
   - `hello`
   - `loops`
   - `switch`
   - `iota`
   - `maps`
   - `slices`
   - `nilvalue`
   - `oddEven`
   - `calc`

   These are likely small demos of core Go syntax, control flow, types, and data structures.

5. `calc` is the only folder whose name suggests a more functional utility-style program, likely demonstrating arithmetic or basic expression handling, but still as a self-contained `main` package.

6. `gocat` stands out as the only area with non-Go content: it includes `lab.txt` alongside `main.go`. That suggests a file-based example, likely reading or processing local input from disk rather than just printing to stdout.

7. `ch1` is a separate boundary because it contains its own `go.mod`. That means it is a distinct Go module, not just another folder in the same module. Architecturally, it is isolated from the root-level examples and may represent a chapter-specific workspace.

8. Data flow across the repository is simple and local:
   - most programs use in-memory values and print results to standard output
   - `gocat` likely adds filesystem input via `lab.txt`
   - there is no evidence of network calls, databases, queues, or external services

9. The dependency surface is minimal and likely limited to the Go standard library. There are no signs of third-party frameworks, service clients, or infrastructure components.

10. From an architecture-diagram perspective, the repo should be drawn as a collection of independent sample executables under one learning workspace, with `ch1` as a separate module boundary and `gocat` as the only folder with file I/O input.

11. The key takeaway is that this repository is intentionally flat and exploratory: each directory is a self-contained experiment, not a layered system with shared business logic.

Main entry points: [`README.md`](https://github.com/vivekvashist/if-err-nil/blob/main/README.md) (Sandbox), [`ch1/go.mod`](https://github.com/vivekvashist/if-err-nil/blob/main/ch1/go.mod) (ch1 module), [`gocat/main.go`](https://github.com/vivekvashist/if-err-nil/blob/main/gocat/main.go) (Go Cat), [`hello/main.go`](https://github.com/vivekvashist/if-err-nil/blob/main/hello/main.go) (Hello)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Root examples"]
  node_hello["Hello<br/>demo main<br/>[main.go]"]
  node_loops["Loops<br/>demo main<br/>[main.go]"]
  node_switch["Switch<br/>demo main<br/>[main.go]"]
  node_iota["Iota<br/>demo main<br/>[main.go]"]
  node_maps["Maps<br/>demo main<br/>[main.go]"]
  node_slices["Slices<br/>demo main<br/>[main.go]"]
  node_nilvalue["Nil Value<br/>demo main<br/>[main.go]"]
  node_oddeven["Odd/Even<br/>demo main<br/>[main.go]"]
  node_calc["Calc<br/>utility demo<br/>[main.go]"]
  node_ch2["Chapter 2<br/>example main<br/>[main.go]"]
end

subgraph group_module["Separate module"]
  node_ch1mod["ch1 module<br/>go module<br/>[go.mod]"]
  node_ch1main["ch1 main<br/>example main<br/>[main.go]"]
end

subgraph group_files["File I/O demo"]
  node_gocat["Go Cat<br/>file demo main<br/>[main.go]"]
  node_lab["lab.txt<br/>sample input<br/>[lab.txt]"]
end

node_repo["Sandbox<br/>learning repo<br/>[README.md]"]

node_repo -->|"contains"| node_hello
node_repo -->|"contains"| node_loops
node_repo -->|"contains"| node_switch
node_repo -->|"contains"| node_iota
node_repo -->|"contains"| node_maps
node_repo -->|"contains"| node_slices
node_repo -->|"contains"| node_nilvalue
node_repo -->|"contains"| node_oddeven
node_repo -->|"contains"| node_calc
node_repo -->|"contains"| node_ch2
node_repo -.->|"separates"| node_ch1mod
node_ch1mod -->|"entry"| node_ch1main
node_repo -->|"contains"| node_gocat
node_gocat -->|"reads"| node_lab

click node_repo "https://github.com/vivekvashist/if-err-nil/blob/main/README.md"
click node_hello "https://github.com/vivekvashist/if-err-nil/blob/main/hello/main.go"
click node_loops "https://github.com/vivekvashist/if-err-nil/blob/main/loops/main.go"
click node_switch "https://github.com/vivekvashist/if-err-nil/blob/main/switch/main.go"
click node_iota "https://github.com/vivekvashist/if-err-nil/blob/main/iota/main.go"
click node_maps "https://github.com/vivekvashist/if-err-nil/blob/main/maps/main.go"
click node_slices "https://github.com/vivekvashist/if-err-nil/blob/main/slices/main.go"
click node_nilvalue "https://github.com/vivekvashist/if-err-nil/blob/main/nilvalue/main.go"
click node_oddeven "https://github.com/vivekvashist/if-err-nil/blob/main/oddEven/main.go"
click node_calc "https://github.com/vivekvashist/if-err-nil/blob/main/calc/main.go"
click node_ch2 "https://github.com/vivekvashist/if-err-nil/blob/main/ch2/main.go"
click node_ch1mod "https://github.com/vivekvashist/if-err-nil/blob/main/ch1/go.mod"
click node_ch1main "https://github.com/vivekvashist/if-err-nil/blob/main/ch1/main.go"
click node_gocat "https://github.com/vivekvashist/if-err-nil/blob/main/gocat/main.go"
click node_lab "https://github.com/vivekvashist/if-err-nil/blob/main/gocat/lab.txt"

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_hello,node_loops,node_switch,node_iota,node_maps,node_slices,node_nilvalue,node_oddeven,node_calc,node_ch2 toneBlue
class node_ch1mod,node_ch1main toneAmber
class node_gocat,node_lab toneMint
class node_repo toneNeutral
```

## Components

### Root examples

Standalone Go learning programs at the repository root

- [Hello](https://github.com/vivekvashist/if-err-nil/blob/main/hello/main.go): demo main · Basic output example · `hello/main.go`
- [Loops](https://github.com/vivekvashist/if-err-nil/blob/main/loops/main.go): demo main · Control-flow example · `loops/main.go`
- [Switch](https://github.com/vivekvashist/if-err-nil/blob/main/switch/main.go): demo main · Branching example · `switch/main.go`
- [Iota](https://github.com/vivekvashist/if-err-nil/blob/main/iota/main.go): demo main · Constant enumeration example · `iota/main.go`
- [Maps](https://github.com/vivekvashist/if-err-nil/blob/main/maps/main.go): demo main · Map usage example · `maps/main.go`
- [Slices](https://github.com/vivekvashist/if-err-nil/blob/main/slices/main.go): demo main · Slice usage example · `slices/main.go`
- [Nil Value](https://github.com/vivekvashist/if-err-nil/blob/main/nilvalue/main.go): demo main · Nil semantics example · `nilvalue/main.go`
- [Odd/Even](https://github.com/vivekvashist/if-err-nil/blob/main/oddEven/main.go): demo main · Parity check example · `oddEven/main.go`
- [Calc](https://github.com/vivekvashist/if-err-nil/blob/main/calc/main.go): utility demo · Small arithmetic-oriented standalone program · `calc/main.go`
- [Chapter 2](https://github.com/vivekvashist/if-err-nil/blob/main/ch2/main.go): example main · Another isolated root-level executable · `ch2/main.go`

### Separate module

A distinct Go module boundary under ch1

- [ch1 module](https://github.com/vivekvashist/if-err-nil/blob/main/ch1/go.mod): go module · Separate Go module boundary · `ch1/go.mod`
- [ch1 main](https://github.com/vivekvashist/if-err-nil/blob/main/ch1/main.go): example main · Entry point inside the separate module · `ch1/main.go`

### File I/O demo

Example that includes local file input

- [Go Cat](https://github.com/vivekvashist/if-err-nil/blob/main/gocat/main.go): file demo main · Standalone example that pairs code with local text input · `gocat/main.go`
- [lab.txt](https://github.com/vivekvashist/if-err-nil/blob/main/gocat/lab.txt): sample input · Local text fixture used by the gocat example · `gocat/lab.txt`

### Other components

- [Sandbox](https://github.com/vivekvashist/if-err-nil/blob/main/README.md): learning repo · Top-level Go learning workspace made of independent examples · `README.md`

## Connections

- Sandbox → Hello: contains · Root sandbox contains independent executable examples
- Sandbox → Loops: contains · Root sandbox contains independent executable examples
- Sandbox → Switch: contains · Root sandbox contains independent executable examples
- Sandbox → Iota: contains · Root sandbox contains independent executable examples
- Sandbox → Maps: contains · Root sandbox contains independent executable examples
- Sandbox → Slices: contains · Root sandbox contains independent executable examples
- Sandbox → Nil Value: contains · Root sandbox contains independent executable examples
- Sandbox → Odd/Even: contains · Root sandbox contains independent executable examples
- Sandbox → Calc: contains · Root sandbox contains independent executable examples
- Sandbox → Chapter 2: contains · Root sandbox contains independent executable examples
- Sandbox → ch1 module: separates · Distinct module boundary under ch1
- ch1 module → ch1 main: entry · Module has its own main package entry point
- Sandbox → Go Cat: contains · Root sandbox contains independent executable examples
- Go Cat → lab.txt: reads · Example likely consumes local file input
