Documentation
¶
Overview ¶
Package collections allows to interact with lists of things.
Deprecated: The collections package is scheduled for removal in Terratest v2. Go's standard library covers these helpers as of Go 1.21+. Replace at the call site:
ListContains(haystack, needle) -> slices.Contains(haystack, needle) ListIntersection / ListSubtract -> a short slices.Contains loop (see each function) GetSliceLastValueE / GetSliceIndexValueE -> strings.Split, then index the result
Index ¶
- func GetSliceIndexValueE(source string, separator string, index int) (string, error)deprecated
- func GetSliceLastValueE(source string, separator string) (string, error)deprecated
- func ListContains(haystack []string, needle string) booldeprecated
- func ListIntersection[T comparable](list1 []T, list2 []T) []Tdeprecated
- func ListSubtract[T comparable](list1 []T, list2 []T) []Tdeprecated
- type SliceValueNotFoundErrordeprecated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSliceIndexValueE
deprecated
added in
v0.30.3
GetSliceIndexValueE will take a source string and returns the value at the given index when split by the separator char.
Deprecated: scheduled for removal in Terratest v2. Use strings.Split at the call site, e.g.:
parts := strings.Split(source, separator) val := parts[index]
Note: bounds-check index first; this helper returned the not-found error for an out-of-range or negative index rather than panicking.
func GetSliceLastValueE
deprecated
added in
v0.30.3
GetSliceLastValueE will take a source string and returns the last value when split by the separator char.
Deprecated: scheduled for removal in Terratest v2. Use strings.Split at the call site, e.g.:
parts := strings.Split(source, separator) last := parts[len(parts)-1]
Note: strings.Split returns the whole string when the separator is absent, so add a strings.Contains check first if you need the not-found error this helper returned.
func ListContains
deprecated
func ListIntersection
deprecated
added in
v0.13.16
func ListIntersection[T comparable](list1 []T, list2 []T) []T
ListIntersection returns all the items in both list1 and list2. Note that this will dedup the items so that the output is more predictable. Otherwise, the end list depends on which list was used as the base.
Deprecated: scheduled for removal in Terratest v2. The collections package is being dropped, so there is no drop-in public replacement; build it inline with the slices package (Go 1.21+) at the call site, e.g.:
out := []T{}
for _, x := range list1 {
if slices.Contains(list2, x) && !slices.Contains(out, x) {
out = append(out, x)
}
}
func ListSubtract
deprecated
func ListSubtract[T comparable](list1 []T, list2 []T) []T
ListSubtract removes all the items in list2 from list1.
Deprecated: scheduled for removal in Terratest v2. The collections package is being dropped, so there is no drop-in public replacement; build it inline with the slices package (Go 1.21+) at the call site, e.g.:
out := []T{}
for _, x := range list1 {
if !slices.Contains(list2, x) {
out = append(out, x)
}
}
Types ¶
type SliceValueNotFoundError
deprecated
added in
v0.30.3
type SliceValueNotFoundError struct {
// contains filtered or unexported fields
}
SliceValueNotFoundError is returned when a provided values file input is not found on the host path.
Deprecated: scheduled for removal in Terratest v2 along with the collections package.
func NewSliceValueNotFoundError
deprecated
added in
v0.30.3
func NewSliceValueNotFoundError(sourceString string) SliceValueNotFoundError
NewSliceValueNotFoundError creates a new slice found error
Deprecated: scheduled for removal in Terratest v2 along with the collections package.
func (SliceValueNotFoundError) Error ¶ added in v0.30.3
func (err SliceValueNotFoundError) Error() string