2023-02-26 23:48:03 +08:00
|
|
|
package nanoid
|
|
|
|
|
|
|
|
import (
|
|
|
|
gonanoid "github.com/matoous/go-nanoid"
|
2023-03-24 11:46:51 +08:00
|
|
|
"matrix-common/pkg/logger"
|
2023-02-26 23:48:03 +08:00
|
|
|
"matrix-middle-service/pkg/config/nanoid"
|
|
|
|
)
|
|
|
|
|
|
|
|
var config *nanoid.Config
|
|
|
|
|
|
|
|
func Init(conf *nanoid.Config) {
|
|
|
|
logger.Log().Debug("[nanoid] 初始化")
|
|
|
|
config = conf
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetNanoId() (string, error) {
|
|
|
|
return gonanoid.Generate(config.Sequence, config.Length)
|
|
|
|
}
|