util

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColorInfo = color.New(color.FgGreen).SprintFunc()

ColorInfo returns a new function that returns info-colorized (green) strings for the given arguments with fmt.Sprint().

Functions

func AsBool

func AsBool(unknown interface{}) (bool, error)

AsBool attempts to convert unknown to a bool

func AsFloat64

func AsFloat64(unknown interface{}) (float64, error)

AsFloat64 attempts to convert unknown to a float64

func AsInt64

func AsInt64(unknown interface{}) (int64, error)

AsInt64 attempts to convert unknown to an int64

func AsMapOfStringsIntefaces

func AsMapOfStringsIntefaces(unknown interface{}) (map[string]interface{}, error)

AsMapOfStringsIntefaces attempts to convert unknown to a map[string]interface{}

func AsSliceOfStrings

func AsSliceOfStrings(unknown interface{}) ([]string, error)

AsSliceOfStrings attempts to convert unknown to a slice of strings

func AsString

func AsString(unknown interface{}) (string, error)

AsString attempts to convert unknown to a string

func Contains

func Contains(arr []string, str string) bool

func DereferenceBool

func DereferenceBool(b *bool) bool

DereferenceBool will return the bool value or the empty value for bool

func DereferenceFloat64

func DereferenceFloat64(f *float64) float64

DereferenceFloat64 will return the float64 value or the empty value for float64

func DereferenceInt

func DereferenceInt(i *int) int

DereferenceInt will return the int value or the empty value for int

func DereferenceInt64

func DereferenceInt64(i *int64) int64

DereferenceInt64 will return the int value or the empty value for i

func DereferenceString

func DereferenceString(s *string) string

DereferenceString will return the string value or the empty value for string

func IsZeroOfUnderlyingType

func IsZeroOfUnderlyingType(x interface{}) bool

IsZeroOfUnderlyingType checks if the underlying type of the interface is set to it's zero value

func ToStructFromMapStringInterface

func ToStructFromMapStringInterface(m map[string]interface{}, str interface{}) error

ToStructFromMapStringInterface marshals a generic map[string]interface{} to a struct by marshalling to json and back Use JSON for the marshalling instead of YAML because sub-structs will get marshalled into map[interface{}]interface{} when using YAML, but map[string]interface{} when using JSON and vault libraries can't handle map[interface{}]interface{}

Types

This section is empty.

Jump to

Keyboard shortcuts

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