common

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StandardPrefix = "am://"
	UserPrefix     = StandardPrefix + "user"
	WorkloadPrefix = StandardPrefix + "workload"
	DataPrefix     = StandardPrefix + "data"
	RolePrefix     = StandardPrefix + "role"
	KeyPrefix      = StandardPrefix + "key"

	AnonymousUser     = UserPrefix + "/***/***"
	AnonymousWorkload = WorkloadPrefix + "/***/***"
	AnonymousDataset  = DataPrefix + "/***/***"
	RedactedRole      = "## Redacted role ##"
)

Variables

View Source
var (
	StandardPattern = regexp.MustCompile(`^` + StandardPrefix + `([a-zA-Z0-9-]+(/[a-zA-Z0-9-]*)*/?)?$`)
)

Functions

func CleanJson

func CleanJson(actual any) string

func Cleanup

func Cleanup(a string) string

Cleanup eliminates double / (except after colon) and trims trailing /

func EqualSets

func EqualSets[T comparable](actual, expected []T) (bool, mapset.Set[T])

func FixJson

func FixJson(b []byte) string

func IsExpired

func IsExpired(endTimeInMilli int64) bool

func Join

func Join(a, b string) string

Join Cleanly concatenates two strings separated by a '/', but avoiding doubled slashes

func Parent

func Parent(path string) string

func PathComponents

func PathComponents(path string) []int

PathComponents returns an array of indexes for all proper component prefixes of a URI omitting the standard lead-in.

For a URI of "am://abc/def/g", this will give back [6, 9, 13, 15]. ``` "am://abc/def/g"[0:6] = "am://" "am://abc/def/g"[0:9] = "am://abc" "am://abc/def/g"[0:13] = "am://abc/def" "am://abc/def/g"[0:15] = "am://abc/def/g" ```

func SafeUnique

func SafeUnique() int64

SafeUnique generates a random integer that javascript won't choke on

func ValidPrincipal

func ValidPrincipal(id string) bool

Types

type VersionMismatchError

type VersionMismatchError struct {
	Msg string
}

func (VersionMismatchError) Error

func (e VersionMismatchError) Error() string

Jump to

Keyboard shortcuts

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