utils

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyEquals

func AnyEquals[T comparable](list []T, value T) bool

func BeginsWith

func BeginsWith(subject, find string) bool

func CreateTempFile added in v0.2.0

func CreateTempFile(content []byte) (string, error)

func EndsWith added in v0.8.0

func EndsWith(subject, find string) bool

func ExtractHeadersFromText added in v1.0.0

func ExtractHeadersFromText(fileContent []byte) map[string]string

func ExtractNumbersFromString added in v0.8.0

func ExtractNumbersFromString(str string) (int, error)

func FilterLines added in v0.2.0

func FilterLines(text string, filterFunc func(line string) bool) string

func GetFreePort added in v1.3.1

func GetFreePort() int

func GetKeys added in v0.0.2

func GetKeys[T_Key comparable, T_Value interface{}](subject map[T_Key]T_Value) []T_Key

func GetSortedKeys added in v0.1.1

func GetSortedKeys[T interface{}](subject map[string]T) []string

func GetWord added in v0.3.0

func GetWord(index int, str, fallback string) string

func HasHeaderWithValue

func HasHeaderWithValue(headers *http.Header, headerKeyToSearch, headerValueToSearch string) bool

func HasText added in v0.2.0

func HasText(text string) bool

func IndexOf added in v0.0.2

func IndexOf[T comparable](list []T, value T) int

func IsPortFree added in v1.3.1

func IsPortFree(portNumber int) bool

func JoinMap

func JoinMap[K comparable, V comparable](mapDst map[K]V, mapSrc map[K]V)

func ListsEqual

func ListsEqual[T comparable](listA []T, listB []T) bool

func ListsEqualUnsorted added in v0.0.2

func ListsEqualUnsorted[T comparable](listA, listB []T) bool

func MapContains

func MapContains[K comparable, V comparable](m map[K]V, key K, value V) bool

func MapContainsX added in v0.8.1

func MapContainsX[K comparable, V comparable](m map[K]V, key K, value, fallback V) (bool, bool, V)

func MapGetKeyByValue added in v1.0.0

func MapGetKeyByValue[K comparable, V comparable](m map[K]V, search V, fallback K) K

func MapMapValueOnly added in v0.0.2

func MapMapValueOnly[T_Key comparable, T_Value comparable, T_ValueB interface{}](
	subject map[T_Key]T_Value,
	transform func(value T_Value) T_ValueB,
) map[T_Key]T_ValueB

func MarshalJsonHelper added in v0.0.2

func MarshalJsonHelper[T comparable](
	mapValues map[T]string,
	errorMessage string,
	value *T,
) ([]byte, error)

func MktempDir

func MktempDir() (string, error)

func ParseEnv added in v0.2.0

func ParseEnv(env map[string]string) []string

func RegexTest added in v1.0.0

func RegexTest(regex string, subject string) bool

func RemoveEmptyLines added in v0.2.0

func RemoveEmptyLines(text string) string

func ReplaceRegex

func ReplaceRegex(subject string, find []string, replaceWith string) string

func ReplaceVars added in v0.4.0

func ReplaceVars(
	text string,
	vars map[string]string,
	toVarPlaceholder func(varName string) string,
) string

func ToCommandParams added in v0.2.0

func ToCommandParams(commandSplit []string) (string, []string)

func ToCommandStrings added in v0.7.0

func ToCommandStrings(command string) []string

func ToDolarSignVariablePlaceHolder added in v0.5.0

func ToDolarSignVariablePlaceHolder(varName string) string

func ToDolarSignWithWrapVariablePlaceHolder added in v0.5.0

func ToDolarSignWithWrapVariablePlaceHolder(varName string) string

func ToHeadersText added in v0.2.0

func ToHeadersText(headers http.Header) string

func UnmarshalJsonHelper added in v0.0.2

func UnmarshalJsonHelper[T comparable](
	value *T,
	mapValues map[T]string,
	data []byte,
	errorMessage string,
) error

func Unquote

func Unquote(subject string) string

func WrapIn added in v0.0.2

func WrapIn(wrapper string) func(subject string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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