encoding

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 5 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Base32Encoder = base32.NewEncoding(specialEncoderKey).WithPadding(base32.NoPadding)

Functions

func FixedLengthUniqueID

func FixedLengthUniqueID(inputID string, maxLength int, options ...Option) (string, error)

FixedLengthUniqueID creates a new UniqueID that is based on the inputID and of a specified length, if the given id is longer than the maxLength.

func FixedLengthUniqueIDForParts

func FixedLengthUniqueIDForParts(maxLength int, parts []string, options ...Option) (string, error)

FixedLengthUniqueIDForParts creates a new uniqueID using the parts concatenated using `-` and ensures that the uniqueID is not longer than the maxLength. In case a simple concatenation yields a longer string, a new hashed ID is created which is always around 8 characters in length.

Types

type Algorithm

type Algorithm uint32

Algorithm defines an enum for the encoding algorithm to use.

const (
	// Algorithm32 uses fnv32 bit encoder.
	Algorithm32 Algorithm = iota

	// Algorithm64 uses fnv64 bit encoder.
	Algorithm64

	// Algorithm128 uses fnv128 bit encoder.
	Algorithm128
)

type AlgorithmOption

type AlgorithmOption struct {
	Option
	// contains filtered or unexported fields
}

AlgorithmOption defines a wrapper to pass the algorithm to encoding functions.

func NewAlgorithmOption

func NewAlgorithmOption(algo Algorithm) AlgorithmOption

NewAlgorithmOption wraps the Algorithm into an AlgorithmOption to pass to the encoding functions.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Jump to

Keyboard shortcuts

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