uuid.go 391 B

12345678910111213141516171819202122
  1. package util
  2. import (
  3. "github.com/GUAIK-ORG/go-snowflake/snowflake"
  4. "github.com/google/uuid"
  5. )
  6. var snowflakeInstance *snowflake.Snowflake
  7. func init() {
  8. s, err := snowflake.NewSnowflake(int64(0), int64(0))
  9. if err != nil {
  10. panic(err)
  11. }
  12. snowflakeInstance = s
  13. }
  14. func GetUUID() string {
  15. return uuid.New().String()
  16. }
  17. func GetSnowflakeID() int64 {
  18. return snowflakeInstance.NextVal()
  19. }