util

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotAPipe = errors.New("this command should be run in a pipe")

Functions

func CmdsContains

func CmdsContains(cmds []*cobra.Command, target *cobra.Command) bool

func IsTerminal

func IsTerminal(v any) bool

IsTerminal checks if an io.Reader or io.Writer is a TTY.

func JoinErrors

func JoinErrors(errs ...error) error

JoinErrors behaves similarly to errors.Join, but returns the error verbatim if there is only 1.

func Must2

func Must2[T any](val T, err error) T

func NewExitCodeError

func NewExitCodeError(code int) error

func Umask

func Umask(mask int) int

Types

type ExitCodeError

type ExitCodeError struct {
	// contains filtered or unexported fields
}

func (ExitCodeError) Error

func (e ExitCodeError) Error() string

func (ExitCodeError) ExitCode

func (e ExitCodeError) ExitCode() int

type SuppressErrorWriter

type SuppressErrorWriter struct {
	Error error
	// contains filtered or unexported fields
}

SuppressErrorWriter proxies writes to another writer. If a write returns an error, the error will be suppressed and the writer will be disabled.

func NewSuppressErrorWriter

func NewSuppressErrorWriter(w io.Writer) *SuppressErrorWriter

func (*SuppressErrorWriter) Close

func (w *SuppressErrorWriter) Close() error

func (*SuppressErrorWriter) Reset

func (w *SuppressErrorWriter) Reset()

func (*SuppressErrorWriter) Write

func (w *SuppressErrorWriter) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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