util

package
v0.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 10 Imported by: 41

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UnsupportedError    = errors.New("not supported")
	NotImplementedError = errors.New("not implemented")
	InvalidFormatError  = errors.New("invalid format")
	UndefinedError      = errors.New("undefined")
	CastingError        = errors.New("failed to convert")
)

Error messages

Functions

func ArrayInterfaceToStr

func ArrayInterfaceToStr(have []interface{}) ([]string, error)

func ArrayStrToInterface

func ArrayStrToInterface(have []string) []interface{}

func AsRFC3339Timestamp

func AsRFC3339Timestamp(t time.Time) string

func Contains

func Contains(needle string, haystack []string) bool

func Copy

func Copy(src interface{}, dst interface{}) error

Copy makes a 1:1 copy of src into dst.

func GetRFC3339Timestamp

func GetRFC3339Timestamp() string

func InterfaceToInterfaceArray

func InterfaceToInterfaceArray(have interface{}) ([]interface{}, error)

InterfaceToInterfaceArray attempts to array-ify an interface type

func InterfaceToStrings

func InterfaceToStrings(have interface{}) ([]string, error)

InterfaceToStrings assumes we are given an interface of either `string`, `[]string` or `[]interface{}` types and attempts to flatten into an array of strings

func IsRFC3339Timestamp

func IsRFC3339Timestamp(t string) bool

IsRFC3339Timestamp attempts to parse a string as an RFC3339 timestamp, which is a subset of an ISO-8601 timestamp. Returns true if the parsing is successful, false if not.

func IsValidStruct

func IsValidStruct(data interface{}) error

func LDNormalize

func LDNormalize(document interface{}) (interface{}, error)

func LoggingError

func LoggingError(err error) error

LoggingError is a utility to combine logging an error, and returning and error

func LoggingErrorMsg

func LoggingErrorMsg(err error, msg string) error

LoggingErrorMsg is a utility to combine logging an error, and returning and error with a message

func LoggingNewError

func LoggingNewError(msg string) error

LoggingNewError is a utility to create an error from a message, log it, and return it as an error

func MergeUniqueValues

func MergeUniqueValues(a, b []string) []string

MergeUniqueValues takes in two string arrays and returns the union set the input arrays are not modified

func NewValidator

func NewValidator() *validator.Validate

func PrettyJSON

func PrettyJSON(data interface{}) ([]byte, error)

PrettyJSON JSON-ifies data in a 'pretty-print' fashion

func StringPtr

func StringPtr(s string) *string

func ToJSON

func ToJSON(i interface{}) (string, error)

func ToJSONInterface

func ToJSONInterface(data string) (interface{}, error)

func ToJSONMap

func ToJSONMap(data interface{}) (map[string]interface{}, error)

Types

type AppendError

type AppendError []string

func NewAppendError

func NewAppendError() *AppendError

func NewAppendErrorFromError

func NewAppendErrorFromError(err error) *AppendError

func (*AppendError) Append

func (a *AppendError) Append(err error)

func (*AppendError) AppendString

func (a *AppendError) AppendString(err string)

func (*AppendError) Error

func (a *AppendError) Error() error

func (*AppendError) IsEmpty

func (a *AppendError) IsEmpty() bool

func (*AppendError) NumErrors

func (a *AppendError) NumErrors() int

type Emptyable

type Emptyable interface {
	IsEmpty() bool
}

type LDProcessor

type LDProcessor struct {
	*ld.JsonLdProcessor
	*ld.JsonLdOptions
}

func NewLDProcessor

func NewLDProcessor() LDProcessor

func (LDProcessor) GetContextFromMap

func (l LDProcessor) GetContextFromMap(dataMap map[string]interface{}) (*ld.Context, error)

func (LDProcessor) GetOptions

func (l LDProcessor) GetOptions() *ld.JsonLdOptions

type Validatable

type Validatable interface {
	IsValid() error
}

Jump to

Keyboard shortcuts

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