core/go
dappco.re/go is the umbrella primitives package. Four universal types form
the surface every operation flows through. The package has zero external
dependencies — go.mod stays at three lines.
Install
Section titled “Install”go get dappco.re/go@latestPrimitives
Section titled “Primitives”| Result | {Value any, OK bool} — replaces the (T, error) pair. Constructors: Ok, Fail, ResultOf, Try. Unwrap: Or, Must, Cast[T], MustCast[T]. |
| Options | Typed key/value bag — the universal input. Accessors: String, Int, Bool, Float64, Duration. |
| Actions | Named, registered, invokable unit of work. Lifecycle (Enable/Disable), composition (Task), background (PerformAsync). |
| Errors | Structured *Err with operation context, stable codes, uniform introspection. Constructors: E, NewError, NewCode, Wrap. |
core.Core | The fractal root. Every operation hangs off c := core.New(). |
Result
Section titled “Result”Construct, branch, and unwrap without ever touching error directly:
r := core.ResultOf(os.ReadFile(path)) // adapt (T, error)if !r.OK { return r }data := r.Value.([]byte)
cfg := core.MustCast[*Config](core.JSONUnmarshal(data, &Config{}))port := opts.Get("port").Or("8080").(string)Actions
Section titled “Actions”Register a named capability, invoke it by name, check entitlements before firing:
c.Action("git.log", func(ctx core.Context, opts core.Options) core.Result { return c.Process().RunIn(ctx, opts.String("dir"), "git", "log")})
r := c.Action("git.log").Run(ctx, core.NewOptions( core.Option{Key: "dir", Value: "/repo"},))Design
Section titled “Design”Every shape decision in core/go propagates to ~30 downstream consumer repos.
The discipline:
- Predictable names over short names — agents grep, not autocomplete.
- Comments as usage examples — every public symbol shows a copy-pastable call.
- Path is documentation — folder structure equals API shape.
- Universal types — Result, Options, Action are everywhere; no bespoke pairs.
- Lib never imports consumer — primitives stay zero-dependency.
Full guide: AGENTS.md in the repo.
Status
Section titled “Status”v0.9.0 — last breaking-change window before the freeze through to v1.0.0-beta.1. Patch releases (v0.9.x) for fixes only.