strutil

package
v2.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertKVStringsToMap

func ConvertKVStringsToMap(values []string) map[string]string

ConvertKVStringsToMap is from https://github.com/moby/moby/blob/v20.10.0-rc2/runconfig/opts/parse.go

ConvertKVStringsToMap converts ["key=value"] to {"key":"value"}

func DedupeStrSlice

func DedupeStrSlice(in []string) []string

func InStringSlice

func InStringSlice(ss []string, str string) bool

InStringSlice checks whether a string is inside a string slice. Comparison is case insensitive.

From https://github.com/containerd/containerd/blob/7c6d710bcfc81a30ac1e8cbb2e6a4c294184f7b7/pkg/cri/util/strings.go#L21-L30

func ParseBoolOrAuto

func ParseBoolOrAuto(s string) (*bool, error)

ParseBoolOrAuto returns (nil, nil) if s is "auto" https://github.com/moby/buildkit/blob/v0.9.1/cmd/buildkitd/config.go#L35-L42

func ParseCSVMap

func ParseCSVMap(s string) (map[string]string, error)

ParseCSVMap parses a string like "foo=x,bar=y" into a map

func ReverseStrSlice

func ReverseStrSlice(in []string) []string

func SliceToSet

func SliceToSet(in []string) map[string]bool

SliceToSet converts a slice of strings into a set. In Go, a set is often represented as a map with keys as the set elements and values as boolean. This function iterates over the slice, adding each string as a key in the map. The corresponding map value is set to true, serving as a placeholder. The resulting map can be used to quickly check the presence of an element in the set.

func TrimStrSliceRight

func TrimStrSliceRight(base, extra []string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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