# wlrgo/optres architecture

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

- Interactive diagram: https://gitdiagram.com/wlrgo/optres
- Repository: https://github.com/wlrgo/optres

## Overview

optres is a small Go library that glues the independent `option.Option` and `result.Result` packages together. Callers choose a conversion: Option-to-Result (`OkOr`, `OkOrElse`), Result-to-Option (`Ok`, `Err`), or one of the two transpose operations. The implementation delegates mapping and construction to the corresponding external package; `OkOr` also delegates to `OkOrElse`. The graph reflects the sampled implementation and README; the external packages’ internals are not represented.

Main entry points: [`optres.go`](https://github.com/wlrgo/optres/blob/main/optres.go) (OkOrElse)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_caller(("Go caller"))
node_okor["OkOr<br/>[optres.go]"]
node_okorelse["OkOrElse<br/>[optres.go]"]
node_ok["Ok<br/>[optres.go]"]
node_err["Err<br/>[optres.go]"]
node_transposeoption["TransposeOption<br/>[optres.go]"]
node_transposeresult["TransposeResult<br/>[optres.go]"]
node_option["option package"]
node_result["result package"]

node_caller -->|"calls"| node_okor
node_caller -->|"calls"| node_okorelse
node_caller -->|"calls"| node_ok
node_caller -->|"calls"| node_err
node_caller -->|"calls"| node_transposeoption
node_caller -->|"calls"| node_transposeresult
node_okor -->|"delegates"| node_okorelse
node_okorelse -->|"maps option"| node_option
node_okorelse -->|"constructs result"| node_result
node_ok -->|"maps result"| node_result
node_ok -->|"constructs option"| node_option
node_err -->|"maps result"| node_result
node_err -->|"constructs option"| node_option
node_transposeoption -->|"maps option"| node_option
node_transposeoption -->|"maps result"| node_result
node_transposeresult -->|"maps result"| node_result
node_transposeresult -->|"maps option"| node_option

click node_okor "https://github.com/wlrgo/optres/blob/main/optres.go"
click node_okorelse "https://github.com/wlrgo/optres/blob/main/optres.go"
click node_ok "https://github.com/wlrgo/optres/blob/main/optres.go"
click node_err "https://github.com/wlrgo/optres/blob/main/optres.go"
click node_transposeoption "https://github.com/wlrgo/optres/blob/main/optres.go"
click node_transposeresult "https://github.com/wlrgo/optres/blob/main/optres.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_caller,node_option,node_result toneIndigo
class node_okor,node_okorelse,node_ok,node_err,node_transposeoption,node_transposeresult toneTeal
```

## Components

### Other components

- **Go caller**
- [OkOr](https://github.com/wlrgo/optres/blob/main/optres.go): `optres.go`
- [OkOrElse](https://github.com/wlrgo/optres/blob/main/optres.go): `optres.go`
- [Ok](https://github.com/wlrgo/optres/blob/main/optres.go): `optres.go`
- [Err](https://github.com/wlrgo/optres/blob/main/optres.go): `optres.go`
- [TransposeOption](https://github.com/wlrgo/optres/blob/main/optres.go): `optres.go`
- [TransposeResult](https://github.com/wlrgo/optres/blob/main/optres.go): `optres.go`
- **option package**
- **result package**

## Connections

- Go caller → OkOr: calls
- Go caller → OkOrElse: calls
- Go caller → Ok: calls
- Go caller → Err: calls
- Go caller → TransposeOption: calls
- Go caller → TransposeResult: calls
- OkOr → OkOrElse: delegates
- OkOrElse → option package: maps option
- OkOrElse → result package: constructs result
- Ok → result package: maps result
- Ok → option package: constructs option
- Err → result package: maps result
- Err → option package: constructs option
- TransposeOption → option package: maps option
- TransposeOption → result package: maps result
- TransposeResult → result package: maps result
- TransposeResult → option package: maps option
