snowflake

package
v0.0.0-...-53df4c2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package snowflake ...

Index

Constants

View Source
const (

	// Nil is a nil/null snowflake.
	Nil = ^Snowflake(0)
)

Variables

View Source
var (
	NodeID = 1
)

Functions

This section is empty.

Types

type Snowflake

type Snowflake uint64

Snowflake represents a snowflake.

Timestamp - 63 to 22 (42 bits) Node ID - 21 to 12 (10 bits) Increment - 11 to 0 (12 bits)

func New

func New() Snowflake

New returns a new snowflake.

func NewAtTime

func NewAtTime(t time.Time) Snowflake

NewAtTime returns a new snowflake using the specified time.

func Parse

func Parse(snowflake string) Snowflake

Parse parses a string into a snowflake.

func (Snowflake) MarshalJSON

func (s Snowflake) MarshalJSON() ([]byte, error)

MarshalJSON satisfies json.Marshaler.

func (Snowflake) String

func (s Snowflake) String() string

String satisfies fmt.Stringer.

func (Snowflake) Time

func (s Snowflake) Time() time.Time

Time returns the time at which the snowflake was generated at.

func (*Snowflake) UnmarshalJSON

func (s *Snowflake) UnmarshalJSON(v []byte) error

UnmarshalJSON satisfies json.Unmarshaler.

func (Snowflake) Valid

func (s Snowflake) Valid() bool

Valid returns true if the snowflake is valid.

Jump to

Keyboard shortcuts

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