result

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Type    ErrorType
	Message string
}

type ErrorType

type ErrorType uint64
const (
	NoError ErrorType = iota
	GrpcError
	LoggerError
	IoError
	LineNumZeroError
	LineNumTooLargeError
	Other
)

type Result

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

func New

func New[T any](ok *T, err *Error) Result[T]

func NewErr

func NewErr[T any](errorType ErrorType, errorMessage string) Result[T]

func NewOk

func NewOk[T any](ok *T) Result[T]

func NewWithTypeAndMessage

func NewWithTypeAndMessage[T any](ok *T, errType ErrorType, errorMessage string) Result[T]

func (Result[T]) Err

func (r Result[T]) Err() *Error

func (Result[T]) IsErr

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

func (Result[T]) IsOk

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

func (Result[T]) Ok

func (r Result[T]) Ok() *T

type ResultInterface

type ResultInterface[T any] interface {
	Ok() *T
	IsOk() bool
	Err() *Error
	IsErr() bool
}

Jump to

Keyboard shortcuts

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