Documentation ¶
Overview ¶
These functions are coming from consul/lib/eof.go
Index ¶
- func CheckHCLKeys(node ast.Node, valid []string) error
- func CheckNamespaceScope(provided string, requested []string) []string
- func CleanEnvVar(s string, r byte) string
- func CleanFilename(filename string, replace string) string
- func CleanFilenameASCIIOnly(filename string, replace string) string
- func CleanFilenameStrict(filename string, replace string) string
- func ConvertSlice[A, B any](original []A, conversion func(a A) B) []B
- func CopyMapOfSlice[K comparable, V any](m map[K][]V) map[K][]V
- func CopySlice[S ~[]E, E Copyable[E]](s S) S
- func DeepCopyMap[M ~map[K]V, K comparable, V Copyable[V]](m M) M
- func ElementsEqual[T EqualFunc[T]](a, b []T) bool
- func HashUUID(input string) (output string, hashed bool)
- func IsDisjoint[T comparable](first, second []T) (bool, []T)
- func IsErrEOF(err error) bool
- func IsMethodHTTP(s string) bool
- func IsSubset[T comparable](larger, smaller []T) (bool, []T)
- func IsUUID(str string) bool
- func IsValidInterpVariable(str string) bool
- func Max[T constraints.Ordered](a, b T) T
- func MergeMapStringString(m map[string]string, n map[string]string) map[string]string
- func Min[T constraints.Ordered](a, b T) T
- func RandomStagger(interval time.Duration) time.Duration
- func RateScaledInterval(rate float64, min time.Duration, n int) time.Duration
- func RemoveEqualFold(xs *[]string, search string)
- func SliceSetEq[T comparable](a, b []T) bool
- func StringHasPrefixInSlice(s string, prefixes []string) bool
- func UniqueMapSliceValues[K, V comparable](m map[K][]V) []V
- func UnusedKeys(obj interface{}) error
- func WithLock(lock sync.Locker, f func())
- type Copyable
- type EqualFunc
- type StopFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckNamespaceScope ¶
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 ¶
CleanEnvVar replaces all occurrences of illegal characters in an environment variable with the specified byte.
func CleanFilename ¶
CleanFilename replaces invalid characters in filename
func CleanFilenameASCIIOnly ¶
CleanFilenameASCIIOnly replaces invalid and non-ASCII characters in filename
func CleanFilenameStrict ¶
CleanFilenameStrict replaces invalid and punctuation characters in filename
func ConvertSlice ¶
func ConvertSlice[A, B any](original []A, conversion func(a A) B) []B
ConvertSlice takes the input slice and generates a new one using the supplied conversion function to covert the element. This is useful when converting a slice of strings to a slice of structs which wraps the string.
func CopyMapOfSlice ¶
func CopyMapOfSlice[K comparable, V any](m map[K][]V) map[K][]V
CopyMapOfSlice creates a copy of m, making copies of each []V.
func CopySlice ¶
func CopySlice[S ~[]E, E Copyable[E]](s S) S
CopySlice creates a deep copy of s. For slices with elements that do not implement Copy(), use slices.Clone.
func DeepCopyMap ¶
func DeepCopyMap[M ~map[K]V, K comparable, V Copyable[V]](m M) M
DeepCopyMap creates a copy of m by calling Copy() on each value.
If m is nil the return value is nil.
func ElementsEqual ¶
ElementsEqual returns true if slices a and b contain the same elements (in no particular order) using the Equal function defined on their type for comparison.
func HashUUID ¶
HashUUID takes an input UUID and returns a hashed version of the UUID to ensure it is well distributed.
func IsDisjoint ¶
func IsDisjoint[T comparable](first, second []T) (bool, []T)
IsDisjoint returns whether first and second are disjoint sets, and the set of offending elements if not.
func IsErrEOF ¶
IsErrEOF returns true if we get an EOF error from the socket itself, or an EOF equivalent error from yamux.
func IsMethodHTTP ¶
IsMethodHTTP returns whether s is a known HTTP method, ignoring case.
func IsSubset ¶
func IsSubset[T comparable](larger, smaller []T) (bool, []T)
IsSubset returns whether the smaller set of items is a subset of the larger. If the smaller set is not a subset, the offending elements are returned.
func IsValidInterpVariable ¶
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 MergeMapStringString ¶
MergeMapStringString will merge two maps into one. If a duplicate key exists the value in the second map will replace the value in the first map. If both maps are empty or nil this returns an empty map.
func RandomStagger ¶
RandomStagger returns an interval between 0 and the duration
func RateScaledInterval ¶
RateScaledInterval is used to choose an interval to perform an action in order to target an aggregate number of actions per second across the whole cluster.
func RemoveEqualFold ¶
RemoveEqualFold removes the first string that EqualFold matches. It updates xs in place
func SliceSetEq ¶
func SliceSetEq[T comparable](a, b []T) bool
SliceSetEq returns true if slices a and b contain the same elements (in no particular order), using '==' for comparison.
Note: for pointers, consider implementing an Equal method and using ElementsEqual instead.
func StringHasPrefixInSlice ¶
StringHasPrefixInSlice returns true if s starts with any prefix in list.
func UniqueMapSliceValues ¶
func UniqueMapSliceValues[K, V comparable](m map[K][]V) []V
UniqueMapSliceValues returns the union of values from each slice in a map[K][]V.
func UnusedKeys ¶
func UnusedKeys(obj interface{}) error
UnusedKeys returns a pretty-printed error if any `hcl:",unusedKeys"` is not empty
Types ¶
type StopFunc ¶
type StopFunc func()
StopFunc is used to stop a time.Timer created with NewSafeTimer
func NewSafeTimer ¶
NewSafeTimer creates a time.Timer but does not panic if duration is <= 0.
Using a time.Timer is recommended instead of time.After when it is necessary to avoid leaking goroutines (e.g. in a select inside a loop).
Returns the time.Timer and also a StopFunc, forcing the caller to deal with stopping the time.Timer to avoid leaking a goroutine.
Note: If creating a Timer that should do nothing until Reset is called, use NewStoppedTimer instead for safely creating the timer in a stopped state.
func NewStoppedTimer ¶
NewStoppedTimer creates a time.Timer in a stopped state. This is useful when the actual wait time will computed and set later via Reset.
Directories ¶
Path | Synopsis |
---|---|
Package boltdd contains a wrapper around BBoltDB to deduplicate writes and encode values using mgspack.
|
Package boltdd contains a wrapper around BBoltDB to deduplicate writes and encode values using mgspack. |
constraints
|
|
semver
semver is a Semver Constraints package copied from github.com/hashicorp/go-version @ 2046c9d0f0b03c779670f5186a2a4b2c85493a71
|
semver is a Semver Constraints package copied from github.com/hashicorp/go-version @ 2046c9d0f0b03c779670f5186a2a4b2c85493a71 |
Package envoy provides a high level view of the variables that go into selecting an envoy version.
|
Package envoy provides a high level view of the variables that go into selecting an envoy version. |
Copied from github.com/hashicorp/consul/sdk/freeport
|
Copied from github.com/hashicorp/consul/sdk/freeport |
grpc-middleware
|
|
Package noxssrw (No XSS ResponseWriter) behaves like the Go standard library's ResponseWriter by detecting the Content-Type of a response if it has not been explicitly set.
|
Package noxssrw (No XSS ResponseWriter) behaves like the Go standard library's ResponseWriter by detecting the Content-Type of a response if it has not been explicitly set. |
pluginutils
|
|
catalog
Package catalog is used to register internal plugins such that they can be loaded.
|
Package catalog is used to register internal plugins such that they can be loaded. |
Package pointer provides helper functions related to Go pointers.
|
Package pointer provides helper functions related to Go pointers. |
Code generated by go generate; DO NOT EDIT.
|
Code generated by go generate; DO NOT EDIT. |
The archive utilities manage the internal format of a snapshot, which is a tar file with the following contents:
|
The archive utilities manage the internal format of a snapshot, which is a tar file with the following contents: |
Package subproc provides helper utilities for executing the Nomad binary as a child process of the Nomad agent.
|
Package subproc provides helper utilities for executing the Nomad binary as a child process of the Nomad agent. |
Package testlog creates a *log.Logger backed by *testing.T to ease logging in tests.
|
Package testlog creates a *log.Logger backed by *testing.T to ease logging in tests. |
Package testtask implements a portable set of commands useful as stand-ins for user tasks.
|
Package testtask implements a portable set of commands useful as stand-ins for user tasks. |