diff --git a/README.md b/README.md index 6d16505..98ad83a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,10 @@ id.Int64() id = NewSnowflake(time.Now()) // returns the int64 as a Snowflake -id = ParseSnowflake(123456789012345678) +id = ParseInt64(123456789012345678) + +// returns the uint64 as a Snowflake +id = ParseUInt64(123456789012345678) // returns a snowflake from an environment variable id = GetSnowflakeEnv("guild_id") diff --git a/snowflake.go b/snowflake.go index 65a42dd..3a808a3 100644 --- a/snowflake.go +++ b/snowflake.go @@ -14,15 +14,18 @@ func NewSnowflake(timestamp time.Time) Snowflake { return Snowflake(strconv.FormatInt(((timestamp.UnixNano()/1_000_000)-Epoch)<<22, 10)) } -// ParseSnowflake parses a Snowflake int64 into a Snowflake +// ParseInt64 parses an int64 into a Snowflake //goland:noinspection GoUnusedExportedFunction -func ParseSnowflake(i int64) Snowflake { - if i == 0 { - return "" - } +func ParseInt64(i int64) Snowflake { return Snowflake(strconv.FormatInt(i, 10)) } +// ParseUInt64 parses an uint64 into a Snowflake +//goland:noinspection GoUnusedExportedFunction +func ParseUInt64(i uint64) Snowflake { + return Snowflake(strconv.FormatUint(i, 10)) +} + // GetSnowflakeEnv returns a new Snowflake from an environment variable //goland:noinspection GoUnusedExportedFunction func GetSnowflakeEnv(key string) Snowflake {