utils

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package utils provides some general purpose utils used within orpheus.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendStringToBinary

func AppendStringToBinary(binary []byte, s string) ([]byte, error)

AppendStringToBinary appends a string to a binary byte slice

func GetSliceDiff

func GetSliceDiff(a []string, b []string) (diff []string)

GetSliceDiff returns all element that are present in slice a but not in b

func IsJSONObject

func IsJSONObject(s string) bool

IsJSONObject checks if a string is a valid json object.

func IsKeyNotFoundError

func IsKeyNotFoundError(err error) bool

IsKeyNotFoundError checks if an error is an KeyNotFound error

func IsSubSlice

func IsSubSlice(needle, haystack []string) bool

IsSubSlice checks if a slice of strings is a subset of another slice

func PrettyPrintJSON

func PrettyPrintJSON(s string) (string, error)

PrettyPrintJSON formats a json-string nicely.

func RandASCIIString

func RandASCIIString(n int) string

RandASCIIString returns a random string consisting of ASCII characters of the given length.

func RemoveStringFromBinary

func RemoveStringFromBinary(binary []byte, s string) ([]byte, error)

RemoveStringFromBinary removes a string from a binary byte slice

func SplitURL

func SplitURL(url string) (scheme, host, path string, err error)

SplitURL splits a url into scheme, host, path or returns an error.

func StringInSlice

func StringInSlice(a string, list []string) bool

StringInSlice check if a given string is present in a slice.

func StructToMap

func StructToMap(i interface{}, tag string) map[string]interface{}

StructToMap creates a map from an interface{} using the passed tag name

Types

type Strings

type Strings []string

Strings is an alias for a string slice

func (Strings) MarshalBinary

func (s Strings) MarshalBinary() ([]byte, error)

MarshalBinary marshals Strings into bytes

func (*Strings) UnmarshalBinary

func (s *Strings) UnmarshalBinary(data []byte) error

UnmarshalBinary unmarshalls bytes into Strings.

Directories

Path Synopsis
Package fileutils provides utility functions related to files.
Package fileutils provides utility functions related to files.
Package logger provides logging functionality.
Package logger provides logging functionality.
Package sstring provides a SensitiveString type that can hold sensitive data.
Package sstring provides a SensitiveString type that can hold sensitive data.
Package times provides constants that expand the ones provided by time.
Package times provides constants that expand the ones provided by time.

Jump to

Keyboard shortcuts

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