util

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanConvert added in v1.8.9

func CanConvert(data interface{}, optionType types.OptionType) (bool, error)

func ConvertString added in v1.8.9

func ConvertString(value string, data any, arg string, delimiterFunc types.ListDelimiterFunc) error

func GetSecureString

func GetSecureString(prompt string, w io.Writer, terminal TerminalReader) (string, error)

GetSecureString reads a password from the terminal

func InsertSlice added in v1.3.3

func InsertSlice[T any](arr []T, pos int, element ...T) []T

InsertSlice inserts item(s) T at position pos and returns a slice

func Min added in v1.8.10

func Min[T Numeric](x, y T) T

func NewOfType added in v1.9.8

func NewOfType[T any](value T) *T

func Reverse added in v1.8.9

func Reverse[T any](s []T)

Reverse reverses the slice in place

func UnwrapType added in v1.9.3

func UnwrapType(t reflect.Type) reflect.Type

UnwrapType recursively unwraps pointer.go types and returns the underlying type

func UnwrapValue added in v1.9.3

func UnwrapValue(v reflect.Value) (reflect.Value, error)

UnwrapValue recursively unwraps pointer and returns the underlying value Returns the zero Value if a nil pointer is encountered

Types

type DefaultTerminal added in v1.8.3

type DefaultTerminal struct{}

DefaultTerminal implements real terminal operations

func (*DefaultTerminal) IsTerminal added in v1.8.3

func (t *DefaultTerminal) IsTerminal(fd int) bool

IsTerminal checks if we are attached to a real terminal

func (*DefaultTerminal) ReadPassword added in v1.8.3

func (t *DefaultTerminal) ReadPassword(fd int) ([]byte, error)

ReadPassword reads a password from the terminal

type Numeric added in v1.8.10

type Numeric interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
		~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 |
		~float32 | ~float64
}

type TerminalReader added in v1.8.3

type TerminalReader interface {
	ReadPassword(fd int) ([]byte, error)
	IsTerminal(fd int) bool
}

TerminalReader interface for reading secure input

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳