util

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(val interface{}, def ...bool) *bool

Bool returns a bool pointer

func CopyStruct

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

CopyStruct copies from one struct to another

func Duration

func Duration(val interface{}) *time.Duration

Duration is a safe time.Duration pointer wrapper

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

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 Float64

func Float64(val interface{}) *float64

Float64 is a safe float64 pointer wrapper

func Int64

func Int64(val interface{}) *int64

Int64 is a safe int64 pointer wrapper

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 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 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{}) 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 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 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 SliceToMap

func SliceToMap(s interface{}, filter ...MapFilter) map[string]interface{}

SliceToMap converts a slice to a map

func String

func String(val interface{}) *string

String is a safe string pointer wrapper

func StringFilter

func StringFilter(ss []string, p func(string) string) []string

StringFilter filters a string

func StringMap

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

func StringPtr

func StringPtr(val interface{}, term ...string) string

StringPtr converts a pointer to normal string or empty

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" }

Types

type Int64Slicer

type Int64Slicer interface {
	ContainsAll(values ...int64) bool
	ContainsAny(values ...int64) bool
	Remove(r int64) Int64Slicer
	Slice() []int64
}

Int64Slicer is the sprocket Int64Slicer interface

func Int64Slice

func Int64Slice(s []int64) Int64Slicer

Int64Slice returns a sprocket Int64Slice

type MapFilter

type MapFilter func(key *string, val interface{}) (interface{}, bool)

MapFilter returns true and the value, or false if the value should be skipped

type Slicer

type Slicer interface {
	ContainsAll(values ...interface{}) bool
	ContainsAny(values ...interface{}) bool
	Remove(r interface{}) Int64Slicer
	Slice() interface{}
}

Slicer is a generic slice manipulation interface helper

type StrMap

type StrMap map[string]*string

func (StrMap) Float64

func (s StrMap) Float64(name string, def ...float64) float64

func (StrMap) String

func (s StrMap) String(name string, def ...string) string

type StrSlicer

type StrSlicer interface {
	ContainsAll(values ...string) bool
	ContainsAny(values ...string) bool
	ContainsStringIgnoreCase(value string) bool
	Remove(r string) StrSlicer
	Slice() []string
	Length() int
}

StrSlicer is the sprocket StrSlicer interface

func StrSlice

func StrSlice(s []string) StrSlicer

StrSlice returns a sprocket StrSlice

Jump to

Keyboard shortcuts

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