Skip to content

Commit

Permalink
update README.md [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyk93 committed Sep 7, 2022
1 parent 3903409 commit 8106767
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,42 @@
# snowid

![workflow badge](https://github.com/guoyk93/snowid/actions/workflows/go.yml/badge.svg) [![Go Reference](https://pkg.go.dev/badge/github.com/guoyk93/snowid.svg)](https://pkg.go.dev/github.com/guoyk93/snowid)

A concurrent-safe lock-free implementation of snowflake algorithm in Golang

## Get

`go get -u github.com/guoyk93/snowflake`

## Usage

```go
// assign a unique identifier
id, _ := strconv.ParseUint(os.Getenv("WORKER_ID"), 10, 64)

// create a instance
s := snowflake.New(snowflake.Options{
Epoch: time.Date(2020, time.January, 1, 0, 0, 0, 0, time.UTC),
ID: id,
})

// get a id
s.NewID()

// stop and release all related resource
s.Stop()
```

## Performance

Less than `1us/op`

## Upstream

https://git.guoyk.net/go-guoyk/snowflake

Due to various reasons, codebase is detached from upstream.

## Credits

Guo Y.K., MIT License

0 comments on commit 8106767

Please sign in to comment.