code

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2020 License: ISC Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Uint64ToString added in v0.10.0

func Uint64ToString(n uint64) string

Uint64ToString converts a number into a string representation

Types

type Builder

type Builder struct {
}

Builder is a factory for codes

func (Builder) New

func (b Builder) New() Code

New creates a new random code

func (Builder) NewFromID

func (b Builder) NewFromID(id uint64) (Code, error)

NewFromID creates a new code from a number

func (Builder) NewFromString

func (b Builder) NewFromString(s string) (Code, error)

NewFromString creates a new code from a string representation (typically a URL path)

type Code

type Code interface {
	String() string
	ID() uint64
}

Code represents a positive integer that also has a human-readable, url-friendly, rather minimalistic representation

type Code64

type Code64 uint64

Code64 is a 64-bit Code

func NewCode64

func NewCode64() Code64

NewCode64 returns a random Code64

func NewCode64FromString added in v0.10.0

func NewCode64FromString(s string) (Code64, error)

NewCode64FromString creates a new Code64 from a string representation

func (Code64) ID

func (c Code64) ID() uint64

ID returns a numeric representation of a 64-bit Code

func (Code64) String

func (c Code64) String() string

String returns a human-readable, url-friendly representation of a 64-bit Code

Jump to

Keyboard shortcuts

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