samber/mo says it has no dependencies while go.mod lists three, and keeps a Go 1.18 file beside a Go 1.22 one
🦄 Monads and popular FP abstractions, powered by Go 1.18+ Generics (Option, Result, Either...)
At a glance
- What is it?
- samber/mo is Samber's MIT-licensed monad library for Go 1.18+ generics, covering Option, Result, Either, IO, Task and State, with the last push on 2026-10-01. The details worth reading are in the build files: a module that declares Go 1.18 and a source file for Go 1.22, and a dependency claim in the README that only holds for the release artefact.
- Who is it for?
- samber/mo is a good fit if you want Option and Result types in Go with real serialisation rather than hand-written wrappers, because the codecs and the database interfaces are already there. Two things to check before committing.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 14 days ago.
- What is it written in?
- Mainly Go, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- samber/mo3,435 ★ · +14
| Repository | 2026-09-24 | 2026-11-15 |
|---|---|---|
| samber/mo | 3.4k | 3.4k |
14 Stars in the last 52 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Option carries seven serialisation methods, including a database scanner
The documented method list for Option[T] is where this library's real weight shows, and the tail of it is the part people skip.
The functional surface is the expected set: IsPresent, IsSome, IsAbsent, IsNone, Size, Get, MustGet, OrElse, OrEmpty, ToPointer, ForEach, Match, Map, MapNone, MapValue and FlatMap. Constructors run from Some and None through TupleToOption, EmptyableToOption and PointerToOption. Option also implements the Foldable type class, which is how the shared combinators apply to more than one type.
Then there are ten methods that have nothing to do with functions. Option implements MarshalJSON and UnmarshalJSON, MarshalText and UnmarshalText, MarshalBinary and UnmarshalBinary, GobEncode and GobDecode, and Scan and Value.
That last pair is the one that matters in production code. Scan and Value are the interfaces for a database driver reading a nullable column, so an Option can be used directly as a scan destination instead of being unpacked by hand at every call site.
A small detail in the same list: most entries link to a playable example, but ForEach, MapNone, MapValue, GobEncode and GobDecode have documentation links only. The playground coverage is therefore partial, which is a gap in the file rather than in the code.
go.mod declares Go 1.18 and the tree contains a Go 1.22 file
The module file states the language version plainly:
module github.com/samber/mo
go 1.18And the top-level listing contains both `option_go118.go` and `option_go122.go`.
Those two filenames are the build-tag mechanism, and they mean Option has at least one implementation split by toolchain version. Under Go 1.18 through 1.21 one file compiles; from 1.22 the other does.
This matters more than a similar split in an application, because the module advertises 1.18 as its floor. A consumer on the floor gets one behaviour, and a consumer on a current toolchain gets another, with no version of the library in between. The README does not describe what differs, only that the two exist.
Go 1.18 is the release that introduced generics, and the whole library depends on them, so the floor is a deliberate choice rather than an accident. The question for an adopter is whether that floor is one you want to keep, and if you build on several Go versions across a fleet, whether the Option behaviour is consistent across them.
No dependencies except the standard library, except for the test graph
The README states that this library has no dependencies except the Go standard library. The module file says something more specific:
//
// Dependencies are excluded from releases. Please check CI.
//
require (
github.com/stretchr/testify v1.12.1
go.uber.org/goleak v1.2.1
)
require go.yaml.in/yaml/v3 v3.0.5 // indirectThree modules are required, and none of them is standard library. What makes the README's claim true is the comment above the block: dependencies are excluded from releases.
So there are two dependency graphs. The one that ships is empty. The one in the checkout, used by the test suite, contains testify for assertions, goleak for goroutine leak detection, and a YAML module arriving indirectly. Anyone building inside the repository pulls all three; anyone importing the released module pulls none.
That arrangement is why the claim is phrased the way it is, and it is also why a security scanner pointed at the repository rather than at your build will report three dependencies that your build never compiles.
The Makefile has a matching target. `make audit` runs `go mod tidy` and then pipes the module list through nancy sleuth, so the project does check its own graph even though the shipped one is empty.
Either ships in four arities, and each has a root file and a subpackage
The layout of the repository is unusual and worth mapping before you read the code.
Every documented type appears twice: once as a file at the root and once as a directory. There is `option.go` and `option/`, `result.go` and `result/`, `either.go` and `either/`, `either3.go` and `either3/`, `either4.go` and `either4/`, `either5.go` and `either5/`. Alongside them sit `io.go`, `io_either.go`, `task.go`, `task_either.go`, `state.go`, `future.go`, and a `typeclass/` directory for the Foldable abstraction, plus `types.go`, `fold.go` and `utils.go`.
The Either family is where the design decision becomes visible. Either is documented as `Either[A, B]`, and there is a separate `EitherX[T1, ..., TX]` with a note that X is between 3 and 5. That produces three extra types, either3, either4 and either5, each with its own file, its own subpackage and its own test file.
So a two-parameter error type becomes five types in the repository, and the arity is carried in the type name rather than in a nesting convention.
There is also `do.go` and `do_test.go` at the root, while the documented list of ten types does not include a Do type and the README points at a separate repository for dependency injection. Whatever that file holds is not in the feature list.
The quick start returns None on purpose, and the last comment is a typo
The first worked example composes three transformations through the option sub-package:
out := option.Pipe3(
mo.Some(21),
option.Map(func(v int) int { return v * 2 }),
option.FlatMap(func(v int) mo.Option[int] { return mo.None[int]() }),
option.Map(func(v int) int { return v + 21 }),
)
// out == None[int]The FlatMap returns None, so the final Map never runs and the result is None. That is short-circuiting demonstrated rather than explained, which is a better choice than a comment saying so.
The second set of examples uses the chained method style. Some(42) goes through three FlatMaps, doubling, taking a remainder of two, and adding twenty-one, then OrElse(1234), with the comment stating the result is 21. OrElse is then shown on a None value returning 1234. Finally Match is called with a two-argument closure for the present case and a zero-argument closure for the absent case.
The comment under that last example reads `// Som`, which is a typo for Some. It is the only broken comment in the examples, and it happens to sit under the one construct where the expected value matters most.
A dot-import escape hatch is offered and then disowned
There is a section on tips for lazy developers, and it is one paragraph.
The author notes they cannot recommend it, but that if you dislike repeating `mo.` everywhere you can import the whole library into the namespace with a dot import:
import (
. "github.com/samber/mo"
)The disclaimer that follows is blunt, to the point of being funny, and the tone is worth reporting as a fact about the project's voice rather than reproducing.
The technical substance is real even so. A dot import of a package with ten exported types puts Option, Result, Either, IO, Task and the rest into your file scope, where a name collision with your own Option is a compile error you will not find by reading the import list. The library's own examples then use unqualified names like Some and Option, which is what a dot-imported call site looks like, so the examples in the quick start and the examples in the API section are written for two different import styles.
The rest of the project is unusually direct in the same way, including a paragraph explaining the name, which is a shortening of Monad Go, chosen partly because no other Go package uses it.
Every type has an example test file, and the Makefile installs its tools at latest
Two details of the developer setup are worth reading before you contribute.
The first is coverage of the documentation. Almost every root type has a companion example test file beside it: `option_example_test.go`, `result_example_test.go`, `either_example_test.go`, `either5_example_test.go`, `future_example_test.go`, `io_example_test.go`, `io_either_example_test.go`, `task_example_test.go`, `fold_example_test.go`, `do_example_test.go`, plus `main_test.go`. Those are what turn the type documentation into runnable snippets, and they are why the API reference is as long as it is.
The second is the tools target in the Makefile. It installs reflex, gotest, go-mod-outdated, goweight, golangci-lint, cover, nancy, benchstat and prettybench, each at its latest tag, and then runs `go mod tidy` at the end.
Installing development tools at latest, with no version pinning, means two contributors on different days get different linters. The `watch-test` target compounds it by driving the suite through reflex with `gotest`, which is a wrapper tool that predates the current one. Meanwhile `test` itself is plain `go test -race -v ./...`, and the race detector on every package is the more meaningful choice for a library full of Future and Task types.
The Makefile also has lint with a 60 second timeout and a cap of 50 identical issues, plus a weight target that reports module size, which is this project's answer to the dependency question.
Eight months between v1.16.0 and v1.17.0, and four months of unreleased commits
Three tagged releases are visible: v1.15.0 on 2025-08-10, v1.16.0 on 2025-09-25 and v1.17.0 on 2026-06-02.
The first two are six weeks apart. The third is eight and a half months after the second, which is a different rhythm for the same minor version line.
The last push to master is dated 2026-10-01, four months after v1.17.0, so there are commits above the newest tag. Nothing in the file explains the gap.
What the README does commit to is stability rather than cadence. The library is v1 and follows SemVer strictly, and no breaking changes will be made to exported APIs before v2.0.0. That is a stronger promise than a release schedule: for a utility library whose types appear in your function signatures, knowing that 1.x will not break you is worth more than knowing how often tags appear.
It also sets the boundary. When 2.0 comes, and the Either arity split and the Go-version-specific files are the kind of thing that changes when a maintainer decides to, the guarantee ends. The `go get` line reinforces the same intent by pinning the major in the import path: `github.com/samber/mo@v1`.
Editorial conclusion
samber/mo is a good fit if you want Option and Result types in Go with real serialisation rather than hand-written wrappers, because the codecs and the database interfaces are already there. Two things to check before committing. Decide whether the Go 1.18 baseline is one you want, since the module declares it while carrying a Go 1.22-specific file, which means behaviour can differ by toolchain. And if you vendor the module for a build pipeline, read go.mod first, because the test dependencies are in the same file as the empty runtime graph.
Frequently asked questions
Which types does samber/mo provide?
Option[T], Result[T], Either[A, B], an EitherX family where the arity is between 3 and 5, Future[T], IO[T], IOEither[T], Task[T], TaskEither[T] and State[S, A]. Inspired by Scala, Rust and FP-TS, and built on Go 1.18 generics.
How do I install samber/mo?
With `go get github.com/samber/mo@v1`, which pins the major version. The README also documents an agent skill install line using npx skills add against the samber/cc-skills-golang repository.
Does samber/mo have any dependencies?
The released module has none beyond the Go standard library. The go.mod in the repository requires testify and goleak for tests plus an indirect YAML module, with a comment stating that dependencies are excluded from releases.
Can an Option be read straight from a database column?
Yes. Option implements Scan and Value, which are the database driver interfaces for reading and writing values, alongside JSON, text, binary and gob marshalling.
What Go version does samber/mo require?
The module declares `go 1.18`, the release that introduced generics. The repository also contains option_go118.go and option_go122.go, so the Option implementation is split by toolchain version.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/samber-mo)Star history chart for your README
[](https://hysenlabs.com/projects/samber-mo)Was this useful?