awesome-go 上面列出来的项目:
- jakehl/goid
- Generate and Parse RFC4122 compliant V4 UUIDs.
- twharmon/gouid
- Generate cryptographically secure random string IDs with just one allocation.
- aidarkhanov/nanoid
- A tiny and efficient Go unique string ID generator.
- muyo/sno
- Compact, sortable and fast unique IDs with embedded metadata.
- oklog/ulid
- Go implementation of ULID (Universally Unique Lexicographically Sortable Identifier).
- uniq - No hassle safe, fast unique identifiers with commands.
- agext/uuid
- Generate, encode, and decode UUIDs v1 with fast or cryptographic-quality random node identifier.
- gofrs/uuid
- Implementation of Universally Unique Identifier (UUID). Supports both creation and parsing of UUIDs. Actively maintained fork of satori uuid.
- google/uuid
- Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
- edwingeng/wuid
- An extremely fast globally unique number generator.
- rs/xid
- Xid is a globally unique id generator library, ready to be safely used directly in your server code.
我自己又在 GitHub 上搜罗了几个:
- lithammer/shortuuid
- 🍄 A generator library for concise, unambiguous and URL-safe UUIDs
- jetpack-io/typeid
- Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
- satori/go.uuid
- UUID package for Go
- segmentio/ksuid
- K-Sortable Globally Unique IDs
package main
import (
"os/exec"
guuid "github.com/google/uuid"
suuid "github.com/satori/go.uuid"
)
func UseGoogle() string {
id := guuid.New()
return id.String()
}
func UseSatori() string {
id := suuid.NewV4()
return id.String()
}
func UseUuidgen() string {
id, _ := exec.Command("uuidgen").Output()
return string(id)
}
func main() {
fmt.Println("Google UUID:", UseGoogle())
fmt.Println("Satori UUID:", UseSatori())
fmt.Println("Uuidgen UUID:", UseUuidgen())
}