utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 8 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 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 HandleEnginePath added in v0.1.1

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

HandleEnginePath handles the engine path if one is specified.

func ParseEnvs added in v0.6.4

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

func PathMap added in v0.1.0

func PathMap(path string, s map[string]interface{}, isSecretPath bool) map[string]interface{}

PathMap takes a path like "a/b/c" and returns a map like map[a] -> map[b] -> map[c]. if isSecretPath is true, then c does not have a / as suffix.

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 TransformMap added in v0.1.0

func TransformMap(p string, m map[string]interface{}, s *map[string]interface{})

TransformMap takes a multi leveled map and returns a map with its combined paths as the keys and the map as its value. Also see TestTransformMap().

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