Skip to content
프로젝트

소개

Go implementation of TypeIDs: type-safe, K-sortable, and globally unique identifiers inspired by Stripe IDs

기타 프로젝트

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
+1
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

TypeID Go

A golang implementation of TypeIDs

License: Apache 2.0 Go Reference

TypeIDs are a modern, type-safe, globally unique identifier based on the upcoming UUIDv7 standard. They provide a ton of nice properties that make them a great choice as the primary identifiers for your data in a database, APIs, and distributed systems. Read more about TypeIDs in their spec.

This particular implementation provides a go library for generating and parsing TypeIDs.

Installation

To add this library as a dependency in your go module, run:

go get go.jetify.com/typeid/v2

Usage

This library provides a go implementation of TypeID:

import (
  "go.jetify.com/typeid/v2"
)

func example() {
  // Generate a new TypeID with a prefix (panics on invalid prefix)
  tid := typeid.MustGenerate("user")
  fmt.Println(tid)
  
  // Generate a new TypeID without a prefix
  tid = typeid.MustGenerate("")
  fmt.Println(tid)
  
  // Generate with error handling
  tid, err := typeid.Generate("user")
  if err != nil {
    log.Fatal(err)
  }
  
  // Parse an existing TypeID
  tid, _ = typeid.Parse("user_00041061050r3gg28a1c60t3gf")
  fmt.Println(tid)
  
  // Convert from UUID
  tid, _ = typeid.FromUUID("user", "018e5f71-6f04-7c5c-8123-456789abcdef")
  fmt.Println(tid)
}

For the full documentation, see this package's godoc.

관련 프로젝트 살펴보기

불러오는 중…