27 lines
438 B
Go
27 lines
438 B
Go
package id
|
|
|
|
import "github.com/renstrom/shortuuid"
|
|
|
|
const (
|
|
shortIDLen = 12
|
|
longIDlen = 16
|
|
)
|
|
|
|
const (
|
|
eventRecordID = "EventRecord-"
|
|
)
|
|
|
|
func newId(prefix string, len int) string {
|
|
uuid := shortuuid.New()
|
|
return prefix + uuid[:len]
|
|
}
|
|
|
|
// newShortID generate short uuid and add type prefix
|
|
func newShortID(prefix string) string {
|
|
return newId(prefix, shortIDLen)
|
|
}
|
|
|
|
func NewEventRecord() string {
|
|
return newShortID(eventRecordID)
|
|
}
|