Documentation
¶
Index ¶
- func CapitalizeFirstLetter(s string) string
- func Clone[T any](val *T) *T
- func Contains[K comparable, V any](m map[K]V, key K) bool
- func Dedent(text string) string
- func EvalContextByFunc(ctx *hcl.EvalContext, name string) *hcl.EvalContext
- func EvalContextByVar(ctx *hcl.EvalContext, name string) *hcl.EvalContext
- func FnMap[I, O any](s []I, fn func(I) O) []O
- func FnMapDiags[I, O any](diags *diagnostics.Diag, s []I, fn func(I) (O, diagnostics.Diag)) []O
- func FnMapErr[I, O any](s []I, fn func(I) (O, error)) (out []O, err error)
- func IsNil(val any) bool
- func JoinSurround(sep, surround string, elems ...string) string
- func MapMap[K comparable, VIn, VOut any](m map[K]VIn, fn func(VIn) VOut) map[K]VOut
- func MapMapDiags[K comparable, VIn, VOut any](diags *diagnostics.Diag, m map[K]VIn, fn func(VIn) (VOut, diagnostics.Diag)) map[K]VOut
- func MapMapErr[K comparable, VIn, VOut any](m map[K]VIn, fn func(VIn) (VOut, error)) (map[K]VOut, error)
- func MemoizedKeys[M ~map[string]V, V any](m *M) func() string
- func Must[T any](val T, err error) T
- func OnceVal[V any](fn func() (V, diagnostics.Diag)) func() (V, diagnostics.Diag)
- func Pop[K comparable, V any](m map[K]V, key K) (val V, found bool)
- func RangeEnd(rng hcl.Range) hcl.Range
- func RangeStart(rng hcl.Range) hcl.Range
- func SetAt[T any](slice []T, idx int, val T) []T
- func SliceToSet[K comparable](slice []K) map[K]struct{}
- func ToHclsyntaxBody(body hcl.Body) *hclsyntax.Body
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CapitalizeFirstLetter ¶
Proper unicode aware capitalization function. If something is wrong – just returns string as is.
func Contains ¶
func Contains[K comparable, V any](m map[K]V, key K) bool
func EvalContextByFunc ¶ added in v0.4.2
func EvalContextByFunc(ctx *hcl.EvalContext, name string) *hcl.EvalContext
func EvalContextByVar ¶ added in v0.4.2
func EvalContextByVar(ctx *hcl.EvalContext, name string) *hcl.EvalContext
func FnMap ¶ added in v0.4.1
func FnMap[I, O any](s []I, fn func(I) O) []O
Produce a new slice by applying function fn to items of the slice s.
func FnMapDiags ¶
func FnMapDiags[I, O any](diags *diagnostics.Diag, s []I, fn func(I) (O, diagnostics.Diag)) []O
Produce a new slice by applying function fn to items of the slice s. Collects slice-like errors from the second return value (diagnostics in our case)
func FnMapErr ¶ added in v0.4.2
Produce a new slice by applying (possibly erroring) function fn to items of the slice s. Returns on the first error with nil slice.
func JoinSurround ¶
func MapMap ¶ added in v0.4.2
func MapMap[K comparable, VIn, VOut any](m map[K]VIn, fn func(VIn) VOut) map[K]VOut
Produce a new map by applying function fn to the values of the map m.
func MapMapDiags ¶
func MapMapDiags[K comparable, VIn, VOut any](diags *diagnostics.Diag, m map[K]VIn, fn func(VIn) (VOut, diagnostics.Diag)) map[K]VOut
Produce a new map by applying function fn to items of the map m. Collects returned diagnostics
func MapMapErr ¶ added in v0.4.2
func MapMapErr[K comparable, VIn, VOut any](m map[K]VIn, fn func(VIn) (VOut, error)) (map[K]VOut, error)
Produce a new map by applying (possibly erroring) function fn to the values of the map m. Returns on the first error with nil map.
func MemoizedKeys ¶
func OnceVal ¶ added in v0.4.2
func OnceVal[V any](fn func() (V, diagnostics.Diag)) func() (V, diagnostics.Diag)
OnceVal returns a function that calls fn only once and caches the result. If fn returns diagnostics with errors, the function will return it only once, on subsequent calls it will return RepeatedError.
func Pop ¶
func Pop[K comparable, V any](m map[K]V, key K) (val V, found bool)
If key in map - return corresponding value and delete it from map
func SetAt ¶ added in v0.4.1
Sets slice[idx] = val, growing the slice if needed, and returns the updated slice.
func SliceToSet ¶
func SliceToSet[K comparable](slice []K) map[K]struct{}
Types ¶
This section is empty.