idKit

package
v1.30.14 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCustomizedNanoId

func NewCustomizedNanoId(alphabet string, size int) (string, error)

NewCustomizedNanoId 生成定制化的NanoId

@param alphabet 字母表(默认为"_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") @param size 生成NanoId字符串的长度

func NewCustomizedULID

func NewCustomizedULID(ms uint64, entropy io.Reader) (string, error)

func NewNanoId

func NewNanoId(l ...int) (string, error)

NewNanoId 生成NanoId

NanoID 了解一下?比 UUID 更好用! - https://mp.weixin.qq.com/s/4muEuUkk3tq6iJXLwspQyQ

@param l 生成NanoId字符串的长度,不传参则默认长度为21(!!!:传参个数只能为0或1,且值>=0) @return 返回值的字母表为: "_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

e.g. () => ("4spQ-UdpjbhSjE046w1Ij", nil)

func NewSimpleUUID

func NewSimpleUUID() string

NewSimpleUUID uuid v4 * @return e.g. "e28351058d0c446b85e3d7896c87078b"

func NewULID

func NewULID() string

NewULID

PS: (1) Format: tttttttttteeeeeeeeeeeeeeee where t is time and e is entropy.(时间+随机数) (2) If you just want to generate a ULID and don't (yet) care about details like performance, cryptographic security, etc., use the ulid.Make helper function.

This function calls time.Now to get a timestamp, and uses a source of entropy which is process-global, pseudo-random, and monotonic.

@return 长度: 26(即ulid.EncodedSize)

e.g. () => "01GMSRXRWJPYSQQZ5Z6T832CSZ"

func NewUUID

func NewUUID() string

NewUUID uuid v4

@return e.g. "fd794d5a-4e7d-456d-a9e4-e377bf00f0a0"

Types

This section is empty.

Jump to

Keyboard shortcuts

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