github.com/go-board/x-go@v0.1.2-0.20220610024734-db1323f6cb15/xseq/id.go (about)

     1  package xseq
     2  
     3  import (
     4  	"github.com/go-board/x-go/xstrings"
     5  	"github.com/gofrs/uuid"
     6  )
     7  
     8  var globalId string
     9  
    10  func init() {
    11  	var err error
    12  	globalId, err = xstrings.FastRandom(32)
    13  	if err != nil {
    14  		globalId = UUID()
    15  	}
    16  }
    17  
    18  func GlobalID() string {
    19  	return globalId
    20  }
    21  
    22  func UUID() string {
    23  	return uuid.Must(uuid.NewV4()).String()
    24  }