util

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExpired is returned when an apns cert is no longer valid
	ErrExpired = errors.New("certificate has expired or is not yet valid")

	// ErrFailedToDecryptKey is returned when the ssl key cannot be decryped
	ErrFailedToDecryptKey = errors.New("failed to decrypt private key")

	// ErrFailedToParsePrivateKey is returned when the ssl private key cannot be parsed
	ErrFailedToParsePrivateKey = errors.New("failed to parse private key")
)
View Source
var FlattenSeparator = "."

FlattenSeparator is what is used by flatten to separate segments

Functions

func CLen added in v1.3.2

func CLen(n []byte) int

CLen gets the C-string length

func CTrim added in v1.3.2

func CTrim(str string) string

CTrim trims a c function

func CopyStruct

func CopyStruct(src, dest interface{}, override bool) error

CopyStruct copies from one struct to another

func EnvMap

func EnvMap(prefix ...string) map[string]interface{}

EnvMap creates a nested map from the os.Environ()

func Expand

func Expand(value map[string]interface{}) map[string]interface{}

func ExpandPrefixed

func ExpandPrefixed(value map[string]interface{}, prefix string) map[string]interface{}

func ExpandPrefixedToResult

func ExpandPrefixedToResult(value map[string]interface{}, prefix string, result map[string]interface{})

func FileBaseName

func FileBaseName(name string) string

FileBaseName returs a path without the extention

func FindFileReverse

func FindFileReverse(name string) (string, error)

FindFileReverse will find an absolute path for a file, from cwd

func Flatten

func Flatten(value interface{}, tags ...string) map[string]interface{}

func FlattenPrefixed

func FlattenPrefixed(value interface{}, prefix string, tags ...string) map[string]interface{}

func FlattenPrefixedToResult

func FlattenPrefixedToResult(value interface{}, prefix string, m map[string]interface{}, tags []string)

func KVMap

func KVMap(vals string, sep ...string) map[string]string

KVMap turns a separated list of values into a map, i.e. username=foo;password=bar

func MapPairs

func MapPairs(cols []string, vals []interface{}, p ...string) map[string]interface{}

func MapSeries

func MapSeries(cols []string, values [][]interface{}, prefix ...string) []map[string]interface{}

func MapStringToInterface

func MapStringToInterface(val map[string]string) map[string]interface{}

func MapStruct

func MapStruct(obj interface{}, input interface{}, tag ...string) error

MapStruct maps the struct into the interface

func MapStructKeys added in v1.3.2

func MapStructKeys(obj interface{}, input interface{}, tag ...string) ([]string, error)

MapStructKeys maps the struct into the interface returning keys mapped

func Max added in v1.3.1

func Max(x, y int) int

Max returns the max of two int64 values

func MaxInt64

func MaxInt64(x, y int64) int64

MaxInt64 returns the max of two int64 values

func MaxInt64Ptr

func MaxInt64Ptr(x, y int64) *int64

MaxInt64Ptr returns the pointer to the min of two int64 values

func MergeStringMaps

func MergeStringMaps(dst, src map[string]string)

func Min added in v1.3.1

func Min(x, y int) int

Min returns the min of two int64 values

func MinInt64

func MinInt64(x, y int64) int64

MinInt64 returns the min of two int64 values

func MinInt64Ptr

func MinInt64Ptr(x, y int64) *int64

MinInt64Ptr returns the pointer to the min of two int64 values

func NormalizeMap

func NormalizeMap(m map[string]interface{}, omitempty ...bool) map[string]interface{}

NormalizeMap normalizes the map values to non-pointer types

func OpenFileReverse

func OpenFileReverse(name string) (*os.File, error)

OpenFileReverse find and open a file in reverse

func ParsePKCS12Certificate added in v1.4.1

func ParsePKCS12Certificate(certData []byte, password ...string) ([]byte, []byte, error)

ParsePKCS12Certificate parses a PKCS12 certificate and returns the public key and the certificate

func PrettyPrint

func PrettyPrint(v interface{}) (err error)

func PrettySprint

func PrettySprint(v interface{}) string

func ProperTitle

func ProperTitle(input string) string

ProperTitle handles properly title casing a string

func RandomString added in v1.3.2

func RandomString(n int) string

RandomString returns a random string

func RemoveWhitespace

func RemoveWhitespace(input string) string

RemoveWhitespace removes all whitespace from a string

func ReverseWalk

func ReverseWalk(start string, walk filepath.WalkFunc) error

ReverseWalk walks up a path

func Slug added in v1.4.1

func Slug(val string) string

Slug slugifies a string

func StringMap

func StringMap(obj interface{}) map[string]string

func StringRemove added in v1.4.8

func StringRemove(s []string, r string) []string

StringRemove removes a string from a string slice

func StructMap

func StructMap(obj interface{}, tag ...string) map[string]interface{}

func SubKeys

func SubKeys(key string) []string

SubKeys splits a dot notation key into sub-parsts, i.e. foo.bar.baz returns []string{ "foo", "foo.bar", "foo.bar.baz" }

func ToSlice added in v1.4.7

func ToSlice(v interface{}) []interface{}

ToSlice casts an interface to an []interace{}

func Unquote added in v1.3.1

func Unquote(s string) string

Unquote does what strconv.Unquote should with single quotes

Types

This section is empty.

Jump to

Keyboard shortcuts

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