misc

package
v5.1.15 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTypeAssert = errors.New("type assert error")

Functions

func BoolP

func BoolP(b bool) *bool

func CamelCase

func CamelCase(fieldName string, initCase bool) string

CamelCase turns snake case to camel case string

func CheckOrCreateWritableDirectory

func CheckOrCreateWritableDirectory(dirname string) (string, error)

func CreateTempDir

func CreateTempDir(config string, createFile bool, extension ...string) (dirname, file string, err error)

CreateTempDir will create a new temporary dir. If config is provided it will create a file with its content

func CreateTypeAssertError

func CreateTypeAssertError(msg string) error

func DashCase

func DashCase(fieldName string) string

DashCase turns camel case to snake case string

func GetObjByField

func GetObjByField(l []interface{}, identifier string, value string) interface{}

GetObjByField returns struct from list l if it has field named identifier with value value

func GetServerAdminState

func GetServerAdminState(state string) (string, error)

GetServerAdminState parses srv_admin_state, srv_admin_state is a mask

func Int64P

func Int64P(i int) *int64

func IsZeroValue

func IsZeroValue(v reflect.Value) bool

IsZeroValue is a helper method for reflect, checks if reflect.Value has zero value

func ObjInArray

func ObjInArray(value string, y []interface{}, identifier string) bool

ObjInArray returns true if struct in list y has field named identifier with value value

func ParseBindAddress

func ParseBindAddress(path string) (string, string, error)

func ParseSize

func ParseSize(size string) *int64

func ParseTimeout

func ParseTimeout(tOut string) *int64

ParseTimeout returns the number of milliseconds in a timeout string.

func ParseTimeoutDefaultSeconds

func ParseTimeoutDefaultSeconds(tOut string) *int64

func Ptr added in v5.0.2

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

func RandomString

func RandomString(n int) string

func SanitizeFilename

func SanitizeFilename(name string) string

SanitizeFilename collapses paths and replaces most non-alphanumeric characters with underscores

func SanitizeIPv6Address

func SanitizeIPv6Address(addr string) string

func SnakeCase

func SnakeCase(fieldName string) string

SnakeCase turns camel case to snake case string

func StringInSlice

func StringInSlice(a string, list []string) bool

StringInSlice checks if a string is in a list of strings

func StringP

func StringP(s string) *string

Types

type Bits

type Bits uint64
const (
	B0 Bits = 1 << iota
	B1
	B2
	B3
	B4
	B5
	B6
	B7
)

func (*Bits) Any

func (b *Bits) Any(flags ...Bits) bool

Jump to

Keyboard shortcuts

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