utils

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Delimiter / delimiter for splitting a path.
	Delimiter = "/"
)

Variables

This section is empty.

Functions

func DeepMergeMaps added in v0.1.1

func DeepMergeMaps(a, b map[string]interface{}) map[string]interface{}

DeepMergeMaps takes two maps and deeply merges them together. https://stackoverflow.com/questions/62953360/golang-merge-deeply-two-maps/62954592#62954592

func FlattenMap added in v0.7.1

func FlattenMap(a, b map[string]interface{}, key string)

FlattenMap flattens a nested map into a single map with its.

func FromJSON added in v0.1.1

func FromJSON(b []byte) (map[string]interface{}, error)

FromJSON takes a json byte array and marshalls it into a map.

func FromYAML added in v0.1.1

func FromYAML(b []byte) (map[string]interface{}, error)

FromYAML takes a yaml byte array and marshalls it into a map.

func GetRootElement added in v0.8.0

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

func HandleEnginePath added in v0.1.1

func HandleEnginePath(enginePath, path string) (string, string)

HandleEnginePath handles the engine path if one is specified.

func NormalizePath added in v0.8.0

func NormalizePath(path string) string

func ParseEnvs added in v0.6.4

func ParseEnvs(prefix string, i interface{}) error

func RemoveCarriageReturns added in v0.2.0

func RemoveCarriageReturns(s string) string

RemoveCarriageReturns removes \r mostly used for unit tests on windows OS.

func RemoveDuplicates added in v0.2.0

func RemoveDuplicates(s []string) []string

RemoveDuplicates removes duplicate elements from a string slice.

func RemoveExtension added in v0.2.0

func RemoveExtension(file string) string

RemoveExtension removes the extension of a specified filename.

func SortMapKeys

func SortMapKeys(m map[string]interface{}) []string

SortMapKeys sorts the keys of a map.

func SplitPath added in v0.0.4

func SplitPath(path string) (string, string)

SplitPath splits a given path by / and returns the first element and the joined rest paths.

func ToJSON

func ToJSON(m interface{}) ([]byte, error)

ToJSON marshalls a given map to json.

func ToMapStringInterface added in v0.0.11

func ToMapStringInterface(i interface{}) map[string]interface{}

ToMapStringInterface takes any value and returns the map string interface.

func ToYAML

func ToYAML(m interface{}) ([]byte, error)

ToYAML marshalls a given map to yaml.

func UnflattenMap added in v0.8.0

func UnflattenMap(path string, data map[string]interface{}, ignoreElements ...string) map[string]interface{}

UnflattenMap takes a path like "a/b/c" and returns a map like map[a] -> map[b] -> map[c]. elements in ignoreElements are not splitted.

Types

type Keys

type Keys []string

Keys type for receiving all keys of a map.

func (Keys) Len

func (k Keys) Len() int

Len returns the length of Keys.

func (Keys) Less

func (k Keys) Less(i, j int) bool

Less compares keys alphabetically.

func (Keys) Swap

func (k Keys) Swap(i, j int)

Swap swaps keys alphabetically.

Jump to

Keyboard shortcuts

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