lib

package
v0.0.0-...-1639680 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEnvironmentStateFile = "/tmp/env-vars"

Location where the environment state from commands are to be captured and sent to for being able to share state across commands.

Functions

func CleanEnvironmentStateFile

func CleanEnvironmentStateFile(path string) error

func CopyMap

func CopyMap(m map[string]string) map[string]string

Makes a copy of a map

func DeleteEnvironmentStateFile

func DeleteEnvironmentStateFile(path string) error

Deletes the stored environment variables file.

func DiffMapsByKey

func DiffMapsByKey(a, b map[string]string) map[string]string

Compares two maps by key and returns the difference between the two. This comparison doesn't take into account the value of the key, only the presence of the key.

func DiffMapsByValue

func DiffMapsByValue(a, b map[string]string) map[string]string

Compares two maps by key and returns the difference between the two based on the value of the key.

func GetDifferenceBetweenStrings

func GetDifferenceBetweenStrings(a, b string) string

func GetEnvironmentVariables

func GetEnvironmentVariables() map[string]string

Get environment variables from the current process.

func GetHomeDirectory

func GetHomeDirectory() (string, error)

func IsNumber

func IsNumber(str string) bool

Checks if a given string is a number.

func LoadEnvironmentStateFile

func LoadEnvironmentStateFile(path string) (map[string]string, error)

Loads a file that contains environment variables

func Max

func Max(x, y int) int

Max returns the larger of x or y.

func MergeMaps

func MergeMaps(a, b map[string]string) map[string]string

Merge two maps together.

func OrderJsonFields

func OrderJsonFields(jsonStr string) (string, error)

Types

type ComparisonResult

type ComparisonResult struct {
	AboveThreshold bool
	Score          float64
}

func CompareJsonStrings

func CompareJsonStrings(
	actualJson string,
	expectedJson string,
	threshold float64,
) (ComparisonResult, error)

Compare two JSON strings by ordering the fields alphabetically and then comparing the strings using the Jaro-Winkler algorithm to compute a score. If the score is greater than the threshold, return true.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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