golang-samber-mo

Implements monadic Option, Result, and Either types in Go using the samber/mo library.

Updated May 9, 2026
One-click install
npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-samber-mo-luminavault
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-samber-mo
Source: https://github.com/LuminaVault/LuminaVaultShared/tree/main/.agents/skills/golang-samber-mo
Command: npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-samber-mo-luminavault

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Go codebases rely on nil pointers, ambiguous zero values, and repetitive if err != nil checks that cause runtime panics and verbose error handling. This Skill guides the correct use of samber/mo monadic types so absence, failure, and multi-type outcomes become explicit in the type system. ## Core Features & Use Cases - Option[T] for nullable values: Replace *string and nil checks with Some/None, with built-in JSON marshaling and sql.Scanner/driver.Valuer support for database columns. - Result[T] and Either[L, R] for error handling: Convert (T, error) tuples with TupleToResult, chain operations with Map/FlatMap, and use Either when both outcomes are valid alternatives. - Type-changing pipelines: Use option/result/either sub-package functions and Pipe1-Pipe10 when transformations change generic types, plus mo.Do for imperative-style monadic code. - Use Case: A Go service scans nullable database rows and returns JSON API responses. Use mo.Option[string] fields so the same struct handles SQL scanning and JSON serialization without custom marshalers or duplicate DTOs. ## Quick Start Ask the AI 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 for row.Scan and inserts, plus json.Marshaler/Unmarshaler so the same struct works for JSON API responses.

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

Use Result[T] when one path is an error, since it is specialized for success/failure with an error type. Use Either[L, R] when both outcomes are valid alternatives, such as cached versus fresh data.

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

Go methods cannot introduce new type parameters, so Option.Map only 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 TupleToResult to convert into Result internally for chaining, then extract with Get() before returning to callers.

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 single-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.