package resultext

import "github.com/go-playground/pkg/v5/values/result"

Index

Types

type Result

type Result[T, E any] struct {
	// contains filtered or unexported fields
}

Result represents the result of an operation that is successful or not.

func Err

func Err[T, E any](err E) Result[T, E]

Err returns a Result that contains the given error.

func Ok

func Ok[T, E any](value T) Result[T, E]

Ok returns a Result that contains the given values.

func (Result[T, E]) Err

func (r Result[T, E]) Err() E

Err returns the error of the result. To be used after calling IsOK()

func (Result[T, E]) IsErr

func (r Result[T, E]) IsErr() bool

IsErr returns true if the result is not successful and has an error.

func (Result[T, E]) IsOk

func (r Result[T, E]) IsOk() bool

IsOk returns true if the result is successful with no error.

func (Result[T, E]) Unwrap

func (r Result[T, E]) Unwrap() T

Unwrap returns the values of the result. It panics if there is no result due to not checking for errors.

Source Files

result.go

Version
v5.12.3
Published
Feb 18, 2023
Platform
linux/amd64
Last checked
6 minutes ago

Tools for package owners.