misc

package
v2.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

func CamelCase

func CamelCase(fieldName string, initCase bool) string

CamelCase turns snake case to camel case string

func CheckOrCreateWritableDirectory added in v2.2.0

func CheckOrCreateWritableDirectory(dirname string) (string, error)

func CreateTempDir added in v2.2.0

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 added in v2.4.9

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 added in v2.2.0

func GetServerAdminState(state string) (string, error)

GetServerAdminState parses srv_admin_state, srv_admin_state is a mask

func Int64P added in v2.0.1

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 ParseSize

func ParseSize(size string) *int64

func ParseTimeout

func ParseTimeout(tOut string) *int64

func RandomString added in v2.2.0

func RandomString(n int) string

func SanitizeFilename added in v2.2.0

func SanitizeFilename(name string) string

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

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 added in v2.2.0

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

func (*Bits) Any added in v2.2.0

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