27 lines
478 B
Go
27 lines
478 B
Go
|
package utils
|
||
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
|
||
|
"github.com/google/uuid"
|
||
|
"github.com/jaevor/go-nanoid"
|
||
|
)
|
||
|
|
||
|
func NanoID() string {
|
||
|
nanoid, _ := nanoid.CustomASCII("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 21)
|
||
|
return nanoid()
|
||
|
}
|
||
|
|
||
|
func NanoIDInt() (id int64, err error) {
|
||
|
decenaryID, err := nanoid.CustomASCII("0123456789", 20)
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
id, err = strconv.ParseInt(decenaryID(), 10, 64)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func UUID() string {
|
||
|
return uuid.NewString()
|
||
|
}
|