Documentation
¶
Index ¶
- Constants
- func DeduplicateStrings(src []string) []string
- func EqualSliceValues[E comparable](s1, s2 []E) bool
- func IsValidKeepMinValue(value int64) (bool, error)
- func MergeSlices[T any](slices ...[]T) []T
- func Paginate[T any](get func(page int) ([]T, error), limit int) ([]T, error)
- func SliceToBoolMap(s []string) map[string]bool
- func StringSliceDeleteEmpty(s []string) []string
- func ValidateDuration(durationStr string) error
- func WithContextSigtermCallback(ctx context.Context, f func()) context.Context
Constants ¶
const MaxPages = 10000
MaxPages bounds how many pages Paginate requests from a single endpoint.
Paginate can only stop once a page comes back shorter than the first one, so an endpoint that ignores the page parameter and keeps answering with the same full page would loop forever while growing the result slice without bound. Bitbucket Cloud's webhook collection does exactly that (issue #1487). The limit is set far above any realistic collection so that it never truncates a legitimate result, and only ever converts a runaway loop into an error.
Variables ¶
This section is empty.
Functions ¶
func DeduplicateStrings ¶
DeduplicateStrings deduplicate string list, empty items are dropped.
func EqualSliceValues ¶
func EqualSliceValues[E comparable](s1, s2 []E) bool
EqualSliceValues compare two slices if they have equal values independent of how they are sorted.
func IsValidKeepMinValue ¶
used to check if project settings value for keepMin is valid. Valid values: -1 (keep all), 0 (use server default), or >0 (specific count).
func MergeSlices ¶
func MergeSlices[T any](slices ...[]T) []T
MergeSlices return a new slice that combines all values of input slices TODO: once https://github.com/golang/go/pull/61817 got merged, we should switch to it
func Paginate ¶
Paginate iterates over a func call until it does not return new items and return it as list.
func SliceToBoolMap ¶
SliceToBoolMap is a helper function to convert a string slice to a map.
func StringSliceDeleteEmpty ¶
StringSliceDeleteEmpty removes empty strings from a string slice.
func ValidateDuration ¶
used to check if project settings value for keepDuration is valid.
Types ¶
This section is empty.