Help us shape the future of Go! Take the 2026 Go Developer Survey

util

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolDerefToPointer

func BoolDerefToPointer(ptr *bool, def bool) *bool

BoolDerefToPointer dereferences the pointer to bool 'ptr', uses 'def' as a default if 'ptr' is nil, and returns a new pointer to the resulting bool.

func DefaultToStringSlice

func DefaultToStringSlice(value []string) []string

DefaultToStringSlice is a helper function that checks if the provided slice is nil and returns an empty string slice in that case. If the slice is not nil, the same slice is returned. The purpose of this function is to avoid nil dereference issues in slices and provide a safe way to default to an empty slice.

func DiffPermissions

func DiffPermissions(a map[string]string, b map[string]string) (map[string]string, map[string]string, map[string]string)

func DiffProtectedBranches

DiffProtectedBranches compares two maps of BranchProtectionRule, map 'a’ and map 'b’. It returns three maps: inANotInB: entities (keys) that are present in 'a' but not in 'b' mapped to their values in 'a' inBNotInA: entities (keys) that are present in 'b' but not in 'a' mapped to their values in 'b' diffs: entities (keys) that are present in both 'a' and 'b' but have different values, mapped to their values in 'b'

func DiffRepositoryRulesets

DiffRepositoryRulesets compares two maps of RepositoryRuleset, 'a' and 'b'. It returns three maps: inANotInB: entities (keys) that are present in 'a' but not in 'b' mapped to their values in 'a' inBNotInA: entities (keys) that are present in 'b' but not in 'a' mapped to their values in 'b' diffs: entities (keys) that are present in both 'a' and 'b' but have different values, mapped to their values in 'b'

func EqualUnordered

func EqualUnordered(a, b []string) bool

EqualUnordered reports whether a and b hold the same strings, ignoring order. nil and empty are equal.

func GenerateSHA1Hash

func GenerateSHA1Hash(s string) string

GenerateSHA1Hash hashes a string to SHA-1

func IntDerefToPointer

func IntDerefToPointer(ptr *int, def int) *int

IntDerefToPointer is a helper function that dereferences a pointer to an int 'ptr', and returns a new pointer to the resulting int. If 'ptr' is nil, it uses 'def' as a default value.

func MergeMaps

func MergeMaps(m1 map[string]string, m2 map[string]string) map[string]string

func SortAndReturn

func SortAndReturn(s []string) []string

SortAndReturn sorts a slice of strings in lexicographical order and returns the sorted slice.

func SortAndReturnPointer

func SortAndReturnPointer(s []string) *[]string

SortAndReturnPointer sorts a slice of strings and returns a pointer to that sorted slice.

func SortByKey

func SortByKey(m map[string]string) map[string]string

func SortRequiredStatusChecks

func SortRequiredStatusChecks(checks []*v1alpha1.RequiredStatusCheck)

SortRequiredStatusChecks sorts a slice of RequiredStatusCheck pointers in-place by the Context field in ascending order.

func SortRulesBypassActors

func SortRulesBypassActors(actors []*v1alpha1.RulesetByPassActors)

SortRulesBypassActors sorts a slice of RulesetByPassActors pointers in-place by ActorType, then ActorID with nil first, then BypassMode.

func SortRulesCodeScanningTools

func SortRulesCodeScanningTools(tools []*v1alpha1.RulesCodeScanningTool)

SortRulesCodeScanningTools sorts a slice of RulesCodeScanningTool pointers in-place by Tool, then AlertsThreshold, then SecurityAlertsThreshold.

func SortRulesRequiredStatusChecks

func SortRulesRequiredStatusChecks(checks []*v1alpha1.RulesRequiredStatusChecksParameters)

SortRulesRequiredStatusChecks sorts a slice of RequiredStatusCheck pointers in-place by the Context field in ascending order, then by IntegrationID with nil first.

func StringDerefToPointer

func StringDerefToPointer(ptr *string, def string) *string

StringDerefToPointer is a helper function that dereferences a pointer to a string 'ptr', and returns a new pointer to the resulting string. If 'ptr' is nil, it uses 'def' as a default value.

func ToLowerSlice

func ToLowerSlice(input []string) []string

ToLowerSlice converts all the strings in the slice to lowercase.

Types

This section is empty.

Jump to

Keyboard shortcuts

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