collections

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: Apache-2.0 Imports: 2 Imported by: 156

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSliceIndexValueE deprecated added in v0.30.3

func GetSliceIndexValueE(source string, separator string, index int) (string, error)

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

func GetSliceLastValueE(source string, separator string) (string, error)

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 ListContains(haystack []string, needle string) bool

ListContains returns true if the given list of strings (haystack) contains the given string (needle).

Deprecated: scheduled for removal in Terratest v2. Replace at the call site with slices.Contains(haystack, needle) (Go 1.21+).

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

Jump to

Keyboard shortcuts

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