utils

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bucketize added in v1.3.1

func Bucketize(value uint, buckets []uint) string

Bucketize will put the value of a metric into the correct bucket, and return the label for it. It is expected that the buckets are already sorted in increasing order and non-empty.

func ContainsForbiddenChars added in v1.14.1

func ContainsForbiddenChars(s string) bool

ContainsForbiddenChars reports whether s contains any characters OpenFGA does not allow.

func Filter added in v1.9.0

func Filter[T any](s []T, predicate func(T) bool) iter.Seq[T]

Filter functions similar to other language list filter functions. It accepts a generic slice and a predicate function to apply to each element, returning an iterator sequence containing only the elements for which the predicate returned true.

Example filtering for even numbers:

iter := Filter([]int{1, 2, 3, 4, 5}, func(n int) bool { return n%2 == 0})
// To collect results: slices.Collect(iter) returns []int{2, 4}

func LinearBuckets added in v1.4.1

func LinearBuckets(minValue, maxValue float64, count int) []float64

LinearBuckets returns an evenly distributed range of buckets in the closed interval [min...max]. The min and max count toward the bucket count since they are included in the range.

func Reduce added in v1.9.0

func Reduce[S ~[]E, E any, A any](s S, initializer A, f func(A, E) A) A

Reduce accepts a generic slice, an initializer value, and a function. It iterates over the slice applying the supplied function to the current accumulated value and each element in the slice, reducing the slice to a single value.

Example reducing to a sum:

Reduce([]int{1, 2, 3}, 0, func(accumulator int, currentValue int) int {
	return accumulator + currentValue
})

returns 6.

Types

This section is empty.

Directories

Path Synopsis
Package apimethod provides a type for the API grpc method names.
Package apimethod provides a type for the API grpc method names.

Jump to

Keyboard shortcuts

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