parent
fdd6dfbc63
commit
50d5b3216c
@ -0,0 +1,28 @@
|
||||
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the MIT License.
|
||||
// If a copy of the MIT was not distributed with this file,
|
||||
// You can obtain one at https://github.com/gogf/gf.
|
||||
|
||||
package gtag
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/internal/json"
|
||||
)
|
||||
|
||||
var (
|
||||
// Type name => enums json.
|
||||
enumsMap = make(map[string]json.RawMessage)
|
||||
)
|
||||
|
||||
// SetGlobalEnums sets the global enums into package.
|
||||
// Note that this operation is not concurrent safety.
|
||||
func SetGlobalEnums(enumsJson string) error {
|
||||
return json.Unmarshal([]byte(enumsJson), &enumsMap)
|
||||
}
|
||||
|
||||
// GetEnumsByType retrieves and returns the stored enums json by type name.
|
||||
// The type name is like: github.com/gogf/gf/v2/encoding/gjson.ContentType
|
||||
func GetEnumsByType(typeName string) string {
|
||||
return string(enumsMap[typeName])
|
||||
}
|
Loading…
Reference in new issue