util

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package util contains several utility functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChildPath

func ChildPath(base, target string) (string, error)

ChildPath returns the child path with respect to the base directory or returns an error if the target directory is not a child of the base directory.

func PathEvalAbs

func PathEvalAbs(path string) (string, error)

PathEvalAbs returns the absolute path for a directory after evaluating symlinks.

func Ptr

func Ptr[T any](v T) *T

Ptr returns the pointer of a given value.

func PtrVal

func PtrVal[T any](v *T) T

PtrVal returns the value of the given pointer. If the provided input is nil, it returns the zero value for the pointer's underlying type.

func SortedMapKeys

func SortedMapKeys[M ~map[K]V, K cmp.Ordered, V any](m M) []K

SortedMapKeys returns the sorted slice of map key strings.

Types

type ExitCodeError added in v1.0.8

type ExitCodeError struct {
	Code int

	// Err may be nil if nothing went wrong, but we still want to exit with a
	// nonzero status
	Err error
}

ExitCodeErr is an implementation of the error interface that contains an command exit status. This is intended to be returned from a Run() function when a command wants to return a specific error code to the OS.

func (*ExitCodeError) Error added in v1.0.8

func (e *ExitCodeError) Error() string

func (*ExitCodeError) Unwrap added in v1.0.8

func (e *ExitCodeError) Unwrap() error

Jump to

Keyboard shortcuts

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