mirror of
https://github.com/weloe/token-go.git
synced 2025-10-05 15:36:50 +08:00
refactor: add constant
This commit is contained in:
9
constant/token_style.go
Normal file
9
constant/token_style.go
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package constant
|
||||||
|
|
||||||
|
const (
|
||||||
|
UUID = "uuid"
|
||||||
|
SimpleUUID = "uuid-simple"
|
||||||
|
RandomString32 = "random-string32"
|
||||||
|
RandomString64 = "random-string64"
|
||||||
|
RandomString128 = "random-string128"
|
||||||
|
)
|
@@ -2,6 +2,7 @@ package model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/weloe/token-go/constant"
|
||||||
"github.com/weloe/token-go/util"
|
"github.com/weloe/token-go/util"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
@@ -41,11 +42,11 @@ func (g *GenerateTokenFunc) GetFunction(tokenForm string) (GenerateFunc, error)
|
|||||||
|
|
||||||
func LoadFunctionMap() GenerateTokenFunc {
|
func LoadFunctionMap() GenerateTokenFunc {
|
||||||
fm := &GenerateTokenFunc{fns: &sync.Map{}}
|
fm := &GenerateTokenFunc{fns: &sync.Map{}}
|
||||||
fm.AddFunc("uuid", util.GenerateUUID)
|
fm.AddFunc(constant.UUID, util.GenerateUUID)
|
||||||
fm.AddFunc("uuid-simple", util.GenerateSimpleUUID)
|
fm.AddFunc(constant.SimpleUUID, util.GenerateSimpleUUID)
|
||||||
fm.AddFunc("random-string32", util.GenerateRandomString32)
|
fm.AddFunc(constant.RandomString32, util.GenerateRandomString32)
|
||||||
fm.AddFunc("random-string64", util.GenerateRandomString64)
|
fm.AddFunc(constant.RandomString64, util.GenerateRandomString64)
|
||||||
fm.AddFunc("random-string128", util.GenerateRandomString128)
|
fm.AddFunc(constant.RandomString128, util.GenerateRandomString128)
|
||||||
|
|
||||||
return *fm
|
return *fm
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user