golang-samber-mo

Implements monadic types in Go using samber/mo for type-safe nullable values and error handling.

Updated Jun 8, 2026
One-click install
npx skills add https://github.com/vovanostm-public/multica --skill golang-samber-mo-vovanostm-public
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-samber-mo
Source: https://github.com/vovanostm-public/multica/tree/main/docs/wiki/architecture/archived-codex-skills/20260525-190000/golang-samber-mo
Command: npx skills add https://github.com/vovanostm-public/multica --skill golang-samber-mo-vovanostm-public

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires github.com/samber/mo, and includes references (resource) components.

What problem does it solve? Go developers face nil pointer panics, repetitive if err != nil checks, and ambiguous zero values when handling nullable data and fallible operations. This Skill provides guidance for using the samber/mo library to make absence and failure explicit in the type system. ## Core Features & Use Cases - Option[T] for nullable values: Replace nil pointers with Some/None types that implement sql.Scanner, driver.Valuer, and JSON marshaling for database models and API responses. - Result[T] and Either[L, R] for error handling: Chain fallible operations with Map, FlatMap, and Pipe functions so errors short-circuit automatically instead of requiring manual checks at each step. - Advanced functional types: Use Future, Task, IO, and State for async computations, deferred side effects, and stateful pipelines. - Use Case: When building a Go API with nullable database columns, use mo.Option[string] fields so the same struct works for both row scanning and JSON responses without custom serialization code. ## Quick Start Ask the agent to refactor a Go function that returns (T, error) into a samber/mo Result pipeline using TupleToResult and FlatMap chaining.

Frequently Asked Questions about golang-samber-mo

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle nullable database columns in Go with samber/mo?▼

Use mo.Option[string] for nullable columns instead of *string. Option implements sql.Scanner and driver.Valuer, so row.Scan and db.Exec work directly, and it also implements json.Marshaler so the same struct serves JSON responses.

When should I use Result vs Either in samber/mo?▼

Use Result[T] when one path is an error, such as a fallible operation. Use Either[L, R] when both outcomes are valid alternatives, like cached versus fresh data, since neither side implies failure.

Why can't Option.Map change the type in samber/mo?▼

Go methods cannot introduce new type parameters, so Option.Map returns Option[T] with the same type. For type-changing transforms like Option[int] to Option[string], use the curried option.Map function from the github.com/samber/mo/option sub-package.

Should I use samber/mo Result for public Go API signatures?▼

No, keep (T, error) at public API boundaries for Go idiom compliance. Use Result internally for chaining multi-step pipelines, converting with TupleToResult at the start and extracting with Get at the end.

What is the difference between Future and Task in samber/mo?▼

Future starts executing immediately upon construction, while Task is lazy and only runs when Run() is called. Task.Run() returns a *Future[T], making Task the right choice for deferred async computations.

When should I avoid using monads in Go?▼

Avoid monads for simple one-step operations where if err != nil is clearer, in performance-critical hot paths, and when zero values are semantically meaningful. Option adds value only when absence differs from the zero value.