From 13d844c130b7d55c8c598842de59391d9c66bc67 Mon Sep 17 00:00:00 2001 From: Ethan Werner Date: Tue, 30 Jun 2026 00:29:48 +0400 Subject: initial commit --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 README.md (limited to 'README.md') diff --git a/README.md b/README.md new file mode 100644 index 0000000..b27ef08 --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# snowflake + +Generate random, URL-safe identifiers in Go. + +Each ID is 16 bytes of cryptographically secure randomness, encoded as a base62 string. + +## install + +```bash +go get git.ethanwerner.com/snowflake +``` + +## usage + +```go +package main + +import ( + "fmt" + + "git.ethanwerner.com/snowflake" +) + +func main() { + id, _ := snowflake.New() + fmt.Println(id) // e.g. "7Kx9mQ2pL4nR8wYv" + fmt.Println(id.Hex()) // e.g. "a1b2c3..." + + parsed, _ := snowflake.FromString(id.String()) +} +``` + +## features + +- Cryptographically secure random IDs +- Base62 and hex encoding/decoding +- `encoding.TextMarshaler` / `json.Marshaler` support +- `database/sql.Scanner` / `driver.Valuer` support + +## license + +MIT -- cgit v1.3.1