result

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package result provides a Result struct to represent the outcome of a tool installation operation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusStrings

func StatusStrings() []string

StatusStrings returns a slice of all String values of the enum

Types

type Result

type Result struct {
	Message string
	Status  Status
	// contains filtered or unexported fields
}

Result represents the outcome of a tool installation operation. It combines a status code with a descriptive message and an optional error.

func New

func New(message string, status Status) Result

New creates a new Result with the specified message and status.

func WithFailed

func WithFailed(message string, errs ...error) Result

WithFailed creates a new Result with a Failed status, message, and optional errors. If multiple errors are provided, they're joined using errors.Join.

func WithOK

func WithOK(message string) Result

WithOK creates a new Result with an OK status and the provided message.

func WithSkipped

func WithSkipped(message string) Result

WithSkipped creates a new Result with a Skipped status and the provided message.

func (Result) AsError

func (r Result) AsError() error

AsError returns an error if the Result represents a failure. Returns nil for successful or skipped results.

func (Result) Error

func (r Result) Error() string

Error implements the error interface.

func (Result) IsFailed

func (r Result) IsFailed() bool

UnsIsFaileduccessful returns true if the Result status is Failed.

func (Result) IsOK

func (r Result) IsOK() bool

IsOK returns true if the Result status is OK.

func (Result) IsSkipped

func (r Result) IsSkipped() bool

IsSkipped returns true if the Result status is Skipped.

func (Result) String added in v0.0.13

func (r Result) String() string

func (Result) Unwrap

func (r Result) Unwrap() error

Unwrap allows for error unwrapping.

func (Result) Wrap

func (r Result) Wrap(err error) Result

Wrap wraps an error with additional context.

func (Result) Wrapped

func (r Result) Wrapped(message string) Result

Wrapped creates a new Result by appending the given message to the existing one. Preserves the original status while extending the message context.

type Status

type Status int

Status represents the possible states of a tool installation operation.

const (
	// OK indicates a successful tool installation.
	OK Status = iota

	// Skipped indicates the tool installation was intentionally skipped.
	Skipped

	// Failed indicates the tool installation encountered an error.
	Failed
)

func StatusString

func StatusString(s string) (Status, error)

StatusString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func StatusValues

func StatusValues() []Status

StatusValues returns all values of the enum

func (Status) IsAStatus

func (i Status) IsAStatus() bool

IsAStatus returns "true" if the value is listed in the enum definition. "false" otherwise

func (Status) String

func (i Status) String() string

Jump to

Keyboard shortcuts

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