init.go 454 B

12345678910111213141516171819202122232425
  1. // Copyright 2019 getensh.com. All rights reserved.
  2. // Use of this source code is governed by getensh.com.
  3. // package id 初始化uniqueId,并提供方法
  4. package id
  5. import (
  6. "time"
  7. "github.com/sony/sonyflake"
  8. )
  9. var sf *sonyflake.Sonyflake
  10. func init() {
  11. st := sonyflake.Settings{
  12. StartTime: time.Date(2010, time.October, 10, 10, 10, 10, 0, time.UTC),
  13. }
  14. sf = sonyflake.NewSonyflake(st)
  15. if sf == nil {
  16. panic("init unique id panic")
  17. }
  18. }