result

package
v1.104.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: BSD-3-Clause Imports: 0 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package result contains the Of result type, which is either a value or an error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Of

type Of[T any] struct {
	// contains filtered or unexported fields
}

Of is either a T value or an error.

Think of it like Rust or Swift's result types. It's named "Of" because the fully qualified name for callers reads result.Of[T].

func Error

func Error[T any](err error) Of[T]

Error returns a new result with error err. If err is nil, the returned result is equivalent to calling Value with T's zero value.

func Value

func Value[T any](v T) Of[T]

Value returns a new result with value v, without an error.

func (Of[T]) Err

func (r Of[T]) Err() error

Err returns r's error, if any. When r.Err returns nil, it's safe to call r.MustValue without it panicking.

func (Of[T]) MustValue

func (r Of[T]) MustValue() T

MustValue returns r's result value. It panics if r.Err returns non-nil.

func (Of[T]) Value

func (r Of[T]) Value() (T, error)

Value returns r's result value and error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL