id

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: Apache-2.0 Imports: 6 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// DefaultShortNameLen is defult length of short name
	DefaultShortNameLen = 8
)

Variables

This section is empty.

Functions

func BaseUUID added in v0.0.2

func BaseUUID() string

BaseUUID generate uuid by base64 encoding

func BytesUUID added in v0.0.2

func BytesUUID() []byte

BytesUUID generate google/uuid as string

func HexUUID added in v0.0.2

func HexUUID(upper bool) string

HexUUID generate uuid by hex encoding

func ShortID added in v0.0.2

func ShortID(n int) string

ShortID generate a random string with length n. If n<=0 it use n as default length(8). NOTE: we suggest n>=8, too short id with higher risk of collision.

func ShortIDWithDic added in v0.0.2

func ShortIDWithDic(n int, dic string, headDicLen int) (string, error)

ShortIDWithDic generate a shortID with dictionary. headDicLen is the length of first byte use. NOTE: it will panic if dic is empty or headDicLen overflow dic.

func ShortIDWithError added in v0.0.2

func ShortIDWithError(n int) (string, error)

ShortIDWithError generate a random string with length n

func String

func String(n int) string

String Generate n length string

func StringUUID added in v0.0.2

func StringUUID() string

StringUUID generate google/uuid as string

func UpperShortID added in v0.0.2

func UpperShortID(n int) string

UpperShortID generate a random string with length n. If n<=0 it use n as default length(8). NOTE: we suggest n>=8, too short id with higher risk of collision. NOTE: it with much more probability to duplicate compare to ShortID.

func WithPrefix added in v0.0.2

func WithPrefix(id string, prefix string) string

WithPrefix add prefix to id if prefix is not empty

Types

This section is empty.

Jump to

Keyboard shortcuts

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