goutils

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultEnvVarPrefix = "APP_"

Variables

View Source
var (
	ErrEmptyEpochString = errors.New("empty epoch string")
	ErrNilRoot          = errors.New("root is nil")
)

Functions

func EpochStringToTime

func EpochStringToTime(s string) (time.Time, error)

func IsTruthy

func IsTruthy(s string) bool

func PanicHandler

func PanicHandler(handler func(err any))

func SplitAny added in v0.1.2

func SplitAny(s string, seps string) []string

SplitAny splits the string s around each instance of one of the Unicode code points in seps.

func TruncateStringWholeWords

func TruncateStringWholeWords(s string, maxLength uint) string

func TruthyValues

func TruthyValues() dsext.Set[string]

func WithFile added in v0.1.2

func WithFile[T any](path string, f func(file *os.File) (T, error)) (T, error)

WithFile opens the file specified by the path using os.Open and calls f with it. The file is closed after f returns.

func WithFileFS added in v0.1.2

func WithFileFS[T any](path string, fs fs.FS, f func(file fs.File) (T, error)) (T, error)

WithFileFS opens the file in filesystem fs specified by the path and calls f with it. The file is closed after f returns.

func WithFileRoot added in v0.1.2

func WithFileRoot[T any](path string, root *os.Root, f func(file *os.File) (T, error)) (T, error)

WithFileRoot opens the file specified by the path within the given root and calls f with it. The file is closed after f returns.

Types

type EnvVarHelper

type EnvVarHelper string

func NewEnvVarHelper

func NewEnvVarHelper(prefix string) EnvVarHelper

func (EnvVarHelper) Bool

func (evh EnvVarHelper) Bool(key string, defaultValue bool) (bool, error)

func (EnvVarHelper) Int

func (evh EnvVarHelper) Int(key string, defaultValue int64) (int64, error)

func (EnvVarHelper) PrefixVar

func (evh EnvVarHelper) PrefixVar(s string) string

Directories

Path Synopsis
Package dsext (data structure extensions) contains extensions to the standard library: slices, maps, and sets (a new type).
Package dsext (data structure extensions) contains extensions to the standard library: slices, maps, and sets (a new type).

Jump to

Keyboard shortcuts

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