code

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: ISC Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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