feat: add usage example

This commit is contained in:
weloe
2023-05-06 23:37:13 +08:00
parent 25f85c7114
commit e831ad6bf6
4 changed files with 171 additions and 2 deletions

View File

@@ -13,6 +13,9 @@ type GenerateTokenFunc struct {
}
func (g *GenerateTokenFunc) Exec(tokenForm string) (string, error) {
if tokenForm == "" {
return "", errors.New("GenerateToken failed: tokenStyle is nil")
}
handlerFunc, err := g.GetFunction(tokenForm)
if err != nil {
return "", err
@@ -30,7 +33,7 @@ func (g *GenerateTokenFunc) GetFunction(tokenForm string) (GenerateFunc, error)
return nil, errors.New("GetFunction() failed: load func error")
}
if value == nil {
return nil, errors.New("GetFunction() failed: func doesn't exist")
return nil, errors.New("GetFunction() failed: this tokenStyle generate func doesn't exist")
}
handlerFunc := value.(GenerateFunc)
return handlerFunc, nil