Back to godoc.org

Package helper

v0.12.5
Latest Go to latest

The latest major version is .

Published: Sep 17, 2020 | License: MPL-2.0 | Module: github.com/hashicorp/nomad

Index

func BoolToPtr

func BoolToPtr(b bool) *bool

boolToPtr returns the pointer to a boolean

func CheckHCLKeys

func CheckHCLKeys(node ast.Node, valid []string) error

func CheckNamespaceScope

func CheckNamespaceScope(provided string, requested []string) []string

CheckNamespaceScope ensures that the provided namespace is equal to or a parent of the requested namespaces. Returns requested namespaces which are not equal to or a child of the provided namespace.

func CleanEnvVar

func CleanEnvVar(s string, r byte) string

CleanEnvVar replaces all occurrences of illegal characters in an environment variable with the specified byte.

func CompareMapStringString

func CompareMapStringString(a, b map[string]string) bool

CompareMapStringString returns true if the maps are equivalent. A nil and empty map are considered not equal.

func CompareSliceSetString

func CompareSliceSetString(a, b []string) bool

CompareSliceSetString returns true if the slices contain the same strings. Order is ignored. The slice may be copied but is never altered. The slice is assumed to be a set. Multiple instances of an entry are treated the same as a single instance.

func CompareTimePtrs

func CompareTimePtrs(a, b *time.Duration) bool

CompareTimePtrs return true if a is the same as b.

func CopyMapStringFloat64

func CopyMapStringFloat64(m map[string]float64) map[string]float64

func CopyMapStringInt

func CopyMapStringInt(m map[string]int) map[string]int

func CopyMapStringInterface

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

func CopyMapStringSliceString

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

CopyMapStringSliceString copies a map of strings to string slices such as http.Header

func CopyMapStringString

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

Helpers for copying generic structures.

func CopyMapStringStruct

func CopyMapStringStruct(m map[string]struct{}) map[string]struct{}

func CopySliceInt

func CopySliceInt(s []int) []int

func CopySliceString

func CopySliceString(s []string) []string

func Float64ToPtr

func Float64ToPtr(f float64) *float64

Float64ToPtr returns the pointer to an float64

func HashUUID

func HashUUID(input string) (output string, hashed bool)

HashUUID takes an input UUID and returns a hashed version of the UUID to ensure it is well distributed.

func Int64ToPtr

func Int64ToPtr(i int64) *int64

Int64ToPtr returns the pointer to an int

func Int8ToPtr

func Int8ToPtr(i int8) *int8

Int8ToPtr returns the pointer to an int8

func IntMax

func IntMax(a, b int) int

func IntMin

func IntMin(a, b int) int

func IntToPtr

func IntToPtr(i int) *int

IntToPtr returns the pointer to an int

func IsUUID

func IsUUID(str string) bool

IsUUID returns true if the given string is a valid UUID.

func IsValidInterpVariable

func IsValidInterpVariable(str string) bool

IsValidInterpVariable returns true if a valid dotted variable names for interpolation. The string must begin with one or more non-dot characters which may be followed by sequences containing a dot followed by a one or more non-dot characters.

func MapStringStringSliceValueSet

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

MapStringStringSliceValueSet returns the set of values in a map[string][]string

func RemoveEqualFold

func RemoveEqualFold(xs *[]string, search string)

RemoveEqualFold removes the first string that EqualFold matches. It updates xs in place

func SliceSetDisjoint

func SliceSetDisjoint(first, second []string) (bool, []string)

func SliceStringContains

func SliceStringContains(list []string, item string) bool

SliceStringContains returns whether item exists at least once in list.

func SliceStringIsSubset

func SliceStringIsSubset(larger, smaller []string) (bool, []string)

SliceStringIsSubset returns whether the smaller set of strings is a subset of the larger. If the smaller slice is not a subset, the offending elements are returned.

func SliceStringToSet

func SliceStringToSet(s []string) map[string]struct{}

func StringToPtr

func StringToPtr(str string) *string

StringToPtr returns the pointer to a string

func TimeToPtr

func TimeToPtr(t time.Duration) *time.Duration

TimeToPtr returns the pointer to a time.Duration.

func Uint64Max

func Uint64Max(a, b uint64) uint64

func Uint64ToPtr

func Uint64ToPtr(u uint64) *uint64

Uint64ToPtr returns the pointer to an uint64

func UintToPtr

func UintToPtr(u uint) *uint

UintToPtr returns the pointer to an uint

func UnusedKeys

func UnusedKeys(obj interface{}) error

UnusedKeys returns a pretty-printed error if any `hcl:",unusedKeys"` is not empty

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier