common

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

README

common

common go utilities

Documentation

Overview

JSON Pointer utilities see: https://datatracker.ietf.org/doc/html/rfc6901

This implementation does not strive to be a perfect implementation of RFC6901. Is is only good enough for the needs of uniond.

Index

Constants

View Source
const (
	UlidByteSize   = 16
	UlidStringSize = 26

	CrockfordCodec = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
)

Variables

View Source
var (
	ErrUnknown      = errors.New("unknown")
	ErrNotFound     = errors.New("not found")
	ErrConflict     = errors.New("conflict")
	ErrBadInput     = errors.New("bad input")
	ErrNotAllowed   = errors.New("not allowed")
	ErrInvalidState = errors.New("invalid state")
)
View Source
var (
	CrockfordEncoding = base32.NewEncoding(CrockfordCodec).WithPadding(base32.NoPadding)
)

Functions

func GroupBy added in v1.3.0

func GroupBy[A any](slice []A, toKey func(A) string) map[string][]A

func Reduce added in v1.3.0

func Reduce[A any, B any](
	slice []A,
	combine func(accumulator B, next A) B,
) B

Types

type AnySlice added in v1.3.0

type AnySlice []any

type M added in v1.3.0

type M map[string]any

func (M) As added in v1.3.0

func (m M) As(receiver any) ([]byte, error)

func (M) Error added in v1.3.0

func (m M) Error() string

func (*M) InsertValueAt added in v1.3.0

func (m *M) InsertValueAt(jsonPointer string, value any) error

type S added in v1.3.1

type S []any

type Set

type Set[A comparable] interface {
	Has(a A) bool
	Add(a A)
	AddAll(a ...A)
	Remove(a A)
	Count() int
	Values() []A
}

func NewSet

func NewSet[A comparable]() Set[A]

type Ulid added in v1.2.0

type Ulid interface {
	TimeBytes() []byte
	EntropyBytes() []byte
	Bytes() []byte
	String() string
	Time() *time.Time
	BitString() string
	Equals(other Ulid) bool
	MarshalJSON() ([]byte, error)
	UnmarshalJSON([]byte) error
}

func MustUlidFromString added in v1.2.0

func MustUlidFromString(encoded string) Ulid

func NewMonotonicUlid added in v1.2.0

func NewMonotonicUlid() Ulid

func NewUlid added in v1.2.0

func NewUlid() Ulid

func NewZeroUlid added in v1.2.0

func NewZeroUlid() Ulid

func UlidFromBytes added in v1.2.0

func UlidFromBytes(bytes []byte) (Ulid, error)

func UlidFromString added in v1.2.0

func UlidFromString(encoded string) (Ulid, error)

func UlidFromTime added in v1.2.0

func UlidFromTime(time time.Time) Ulid

Jump to

Keyboard shortcuts

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