Skip to content

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.

Terminal window
go get dappco.re/go@latest
Result{Value any, OK bool} — replaces the (T, error) pair. Constructors: Ok, Fail, ResultOf, Try. Unwrap: Or, Must, Cast[T], MustCast[T].
OptionsTyped key/value bag — the universal input. Accessors: String, Int, Bool, Float64, Duration.
ActionsNamed, registered, invokable unit of work. Lifecycle (Enable/Disable), composition (Task), background (PerformAsync).
ErrorsStructured *Err with operation context, stable codes, uniform introspection. Constructors: E, NewError, NewCode, Wrap.
core.CoreThe fractal root. Every operation hangs off c := core.New().

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)

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"},
))

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.

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.