utils

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppConfigDirOrDefault

func AppConfigDirOrDefault(defaultAppConfigDir string, toolName string) string

AppConfigDirOrDefault returns the app config directory

func CreateFileWithSafe added in v1.0.0

func CreateFileWithSafe(filename string, appendToFile bool, overwrite bool) (*os.File, error)

func ExtractPhoneDigits added in v1.3.2

func ExtractPhoneDigits(input string) string

ExtractPhoneDigits strips all non-digit characters from a phone number string, preserving the original digit order. This normalizes inputs like:

"+1 (555) 234 10 96"  → "15552341096"
"+998-50-123-45-67"   → "998501234567"
"15551234567"         → "15551234567"

func FileExists

func FileExists(filename string) bool

FileExists checks if the file exists in the provided path

func GetEnvOrDefault

func GetEnvOrDefault[T EnvType](key string, defaultValue T) T

GetEnvOrDefault returns the value of the environment variable or the default value if the variable is not set. in requested type.

func HasStdin added in v1.0.4

func HasStdin() bool

HasStdin determines if the user has piped input

func IsAndroid added in v1.0.4

func IsAndroid() bool

func IsFreeBSD added in v1.0.4

func IsFreeBSD() bool

func IsIOS added in v1.0.4

func IsIOS() bool

func IsJS added in v1.0.4

func IsJS() bool

func IsLinux added in v1.0.4

func IsLinux() bool

func IsOSX added in v1.0.4

func IsOSX() bool

func IsOpenBSD added in v1.0.4

func IsOpenBSD() bool

func IsSolaris added in v1.0.4

func IsSolaris() bool

func IsWindows added in v1.0.4

func IsWindows() bool

func ParseTargets

func ParseTargets(targets string, stdin bool) (io.Reader, error)

func PickRandom added in v1.0.0

func PickRandom[T any](v []T, sourceName string, needsKey bool) T

func UserConfigDirOrDefault

func UserConfigDirOrDefault(defaultConfigDir string) string

UserConfigDirOrDefault returns the user config directory or defaultConfigDir in case of error

Types

type EnvType

type EnvType interface {
	~string | ~int | ~bool | ~float64 | time.Duration | ~rune
}

EnvType is a type that can be used as a type for environment variables.

type OsType added in v1.0.4

type OsType uint8
const (
	Darwin OsType = iota

	Linux
	Android
	IOS
	FreeBSD
	OpenBSD
	JS
	Solaris
	UnknownOS
)
var OS OsType

Jump to

Keyboard shortcuts

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