github.com/andersfylling/snowflake/v5@v5.0.1/README.md (about)

     1  # Snowflake [![GoDoc](https://godoc.org/github.com/andersfylling/snowflake?status.svg)](https://godoc.org/github.com/andersfylling/snowflake) [![codecov](https://codecov.io/gh/andersfylling/snowflake/branch/master/graph/badge.svg?token=w5FS4B9fou)](https://codecov.io/gh/andersfylling/snowflake) [![Go Report Card](https://goreportcard.com/badge/github.com/andersfylling/snowflake)](https://goreportcard.com/report/github.com/andersfylling/snowflake)
     2  [![forthebadge](https://forthebadge.com/images/badges/made-with-go.svg)](https://forthebadge.com)[![forthebadge](https://forthebadge.com/images/badges/built-with-love.svg)](https://forthebadge.com)
     3  
     4  > This lib supports signed numbers, but will convert them to uint64.
     5  
     6  Does not hold functionality to connect a snowflake service, nor generating snowflakes. But supports parsing snowflakes sent by Discord (both integer and string), and renders zero value as "null" and higher values as a string version to comply with Discord.
     7  
     8  For module usage you must utilise the suffix found in the go.mod file (/v2 for v2.x.x releases, /v3 for v3.x.x releases, etc.).
     9  
    10  Usage:
    11  >Note: if you are against dot imports, which I can understand, instead of writing snowflake.Snowflake, you can write snowflake.ID. ID is just an alias for Snowflake.
    12  
    13  ```go
    14  import . "github.com/andersfylling/snowflake/v5"
    15  
    16  type DiscordRole struct {
    17      ID          Snowflake    `json:"id"`
    18      Name        string       `json:"name"`
    19      Managed     bool         `json:"managed"`
    20      Mentionable bool         `json:"mentionable"`
    21      Hoist       bool         `json:"hoist"`
    22      Color       int          `json:"color"`
    23      Position    int          `json:"position"`
    24      Permissions uint64       `json:"permissions"`
    25  }
    26  ```
    27  
    28  If you're creating an API that sends JSON, the snowflake will automatically be converted to/from a string for you.
    29  
    30  ### Benchmarks
    31  
    32  ```markdown
    33  name                              time/op
    34  UnmarshalJSON/string-8            52.5ns ±14%
    35  UnmarshalJSON/snowflake-8         23.0ns ± 6%
    36  UnmarshalJSON/string-struct-8     1.23µs ± 5%
    37  UnmarshalJSON/snowflake-struct-8  1.15µs ±10%
    38  NullCheck/string-8                0.58ns ± 8%
    39  ```