Documentation ¶
Index ¶
- Constants
- Variables
- func AnyToJSONInterface(data any) (any, error)
- func ArrayInterfaceToStr(have []any) ([]string, error)
- func ArrayStrToInterface(have []string) []any
- func AsRFC3339Timestamp(t time.Time) string
- func Contains(needle string, haystack []string) bool
- func Copy(src any, dst any) error
- func GetRFC3339Timestamp() string
- func InterfaceToInterfaceArray(have any) ([]any, error)
- func InterfaceToStrings(have any) ([]string, error)
- func IsRFC3339Timestamp(t string) bool
- func IsValidStruct(data any) error
- func LDCompact(document any, context string) (map[string]any, error)
- func LDFrame(document any, frame any) (any, error)
- func LDNormalize(document any) (any, error)
- func LoggingError(err error) error
- func LoggingErrorMsg(err error, msg string) error
- func LoggingErrorMsgf(err error, msg string, args ...any) error
- func LoggingNewError(msg string) error
- func LoggingNewErrorf(msg string, args ...any) error
- func MergeUniqueValues(a, b []string) []string
- func NewValidator() *validator.Validate
- func PrettyJSON(data any) ([]byte, error)
- func SanitizeLog(log string) string
- func StringPtr(s string) *string
- func ToJSON(i any) (string, error)
- func ToJSONInterface(data string) (any, error)
- func ToJSONMap(data any) (map[string]any, error)
- type AppendError
- type Emptyable
- type LDProcessor
- type URL
- type Validatable
Constants ¶
const JSONContentType = "application/json"
Variables ¶
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 AnyToJSONInterface ¶
func ArrayInterfaceToStr ¶
func ArrayStrToInterface ¶
func AsRFC3339Timestamp ¶
func GetRFC3339Timestamp ¶
func GetRFC3339Timestamp() string
func InterfaceToInterfaceArray ¶
InterfaceToInterfaceArray attempts to array-ify an interface type
func InterfaceToStrings ¶
InterfaceToStrings assumes we are given an interface of either `string`, `[]string` or `[]any` types and attempts to flatten into an array of strings
func IsRFC3339Timestamp ¶
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 LDCompact ¶
LDCompact runs https://www.w3.org/TR/json-ld-api/#compaction-algorithms which shortens IRIs in the document
func LDFrame ¶
LDFrame runs https://www.w3.org/TR/json-ld11-framing/ to transform the data in a document according to its frame
func LDNormalize ¶
func LoggingError ¶
LoggingError is a utility to combine logging an error, and returning and error
func LoggingErrorMsg ¶
LoggingErrorMsg is a utility to combine logging an error, and returning and error with a message
func LoggingErrorMsgf ¶
LoggingErrorMsgf is a utility to combine logging an error, and returning and error with a formatted message
func LoggingNewError ¶
LoggingNewError is a utility to create an error from a message, log it, and return it as an error
func LoggingNewErrorf ¶
LoggingNewErrorf is a utility to create an error from a formatted message, log it, and return it as an error
func MergeUniqueValues ¶
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 ¶
PrettyJSON JSON-ifies data in a 'pretty-print' fashion
func SanitizeLog ¶
SanitizeLog prevents certain classes of injection attacks before logging https://codeql.github.com/codeql-query-help/go/go-log-injection/
func ToJSONInterface ¶
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 LDProcessor ¶
type LDProcessor struct { *ld.JsonLdProcessor *ld.JsonLdOptions }
func NewLDProcessor ¶
func NewLDProcessor() LDProcessor
func (LDProcessor) GetContextFromMap ¶
func (LDProcessor) GetOptions ¶
func (l LDProcessor) GetOptions() *ld.JsonLdOptions
type URL ¶
URL is a wrapper struct of url.URL in order to unmarshal(marshal) URLs from(to) strings.
func (URL) MarshalJSON ¶
func (*URL) UnmarshalJSON ¶
type Validatable ¶
type Validatable interface {
IsValid() error
}