utils

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2016 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SkipReflection = errors.New("skip this value")

Functions

func BuildTypeName

func BuildTypeName(t reflect.Type) string

func ExpandPath

func ExpandPath(p string) string

ExpandPath replaces common path aliases: ~ -> $HOME

func InvokeMethod

func InvokeMethod(target interface{}, name string, args ...interface{}) ([]reflect.Value, error)

InvokeMethod calls the specified method by reflection

func IsPrimitiveValue

func IsPrimitiveValue(v reflect.Value) bool

IsPrimitiveValue returns true if passed a value of primitive type: int, bool, etc Note that string (like []byte) is not treated as a primitive type

func JsonMergeStruct

func JsonMergeStruct(dest, src interface{})

JsonMergeStruct merges src into dest It uses a JSON marshal & unmarshal, so only fields that are JSON-visible will be copied

func ReflectRecursive

func ReflectRecursive(v reflect.Value, visitor visitorFunc) error

ReflectRecursive calls visitor with v and every recursive sub-value, skipping subtrees if SkipReflection is returned

func SanitizeString

func SanitizeString(s string) string

func StringSlicesEqual

func StringSlicesEqual(l, r []string) bool

func StringSlicesEqualIgnoreOrder

func StringSlicesEqualIgnoreOrder(l, r []string) bool

func YamlMarshal

func YamlMarshal(o interface{}) ([]byte, error)

func YamlToJson

func YamlToJson(yamlBytes []byte) ([]byte, error)

func YamlUnmarshal

func YamlUnmarshal(yamlBytes []byte, dest interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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