Documentation
¶
Index ¶
- Constants
- type ID
- type Snowflake
- func (s Snowflake) Date() time.Time
- func (s Snowflake) DateByEpoch(epoch uint64) time.Time
- func (s Snowflake) HexPrettyString() string
- func (s Snowflake) HexString() string
- func (s Snowflake) IsZero() bool
- func (s Snowflake) JSONStruct() *SnowflakeJSON
- func (s Snowflake) MarshalBinary() (data []byte, err error)
- func (s Snowflake) MarshalJSON() (data []byte, err error)
- func (s Snowflake) MarshalText() (text []byte, err error)
- func (s Snowflake) String() string
- func (s *Snowflake) UnmarshalBinary(text []byte) (err error)
- func (s *Snowflake) UnmarshalJSON(data []byte) (err error)
- func (s *Snowflake) UnmarshalText(text []byte) (err error)
- func (s Snowflake) Valid() bool
- type SnowflakeJSON
Constants ¶
View Source
const ( EpochDiscord uint64 = 1420070400000 EpochTwitter uint64 = 1288834974657 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Snowflake ¶
type Snowflake uint64
Snowflake twitter snowflake design
func GetSnowflake ¶
func NewSnowflake ¶
NewID creates a new Snowflake Snowflake from a uint64.
func ParseSnowflakeString ¶
ParseSnowflakeString interprets a string with a decimal number.
Note that in contrast to ParseUint, this function assumes the given string is always valid and thus will panic rather than return an error. This should only be used on checks that can be done at compile time, unless you want to trust other modules to returns valid data.
func ParseSnowflakeUint ¶
ParseUint converts a string and given base to a Snowflake
func (Snowflake) HexPrettyString ¶
HexPrettyString converts the Snowflake into a hexadecimal string with the hex prefix 0x
func (Snowflake) IsZero ¶
IsZero since snowflake exists of several parts, including a timestamp,
I assume a valid snowflake Snowflake is never 0.
func (Snowflake) JSONStruct ¶
func (s Snowflake) JSONStruct() *SnowflakeJSON
JSONStruct returns a struct that can be embedded in other structs.
This is useful if you have a API server, since js can't parse uint64. Therefore there must a snowflake Snowflake string.
func (Snowflake) MarshalBinary ¶
MarshalBinary create a binary literal representation as a string
func (Snowflake) MarshalJSON ¶
func (Snowflake) MarshalText ¶
func (*Snowflake) UnmarshalBinary ¶
func (*Snowflake) UnmarshalJSON ¶
func (*Snowflake) UnmarshalText ¶
type SnowflakeJSON ¶
JSON can be useful when sending the snowflake Snowflake by a json API
Click to show internal directories.
Click to hide internal directories.