Documentation ¶
Index ¶
- Constants
- Variables
- func ConvertToViewTree(treeDatas []map[string]interface{}, labelField, valueField, keyField string) []map[string]interface{}
- func FromTraceIDContext(ctx context.Context) string
- func FromUserIDContext(ctx context.Context) string
- func GetLevelCode(orderLevelCodes []string) string
- func JSONMarshalToString(v interface{}) string
- func MD5Hash(b []byte) string
- func MD5HashString(s string) string
- func MustUUID() string
- func NewTraceIDContext(ctx context.Context, traceID string) context.Context
- func NewUUID() (string, error)
- func NewUserIDContext(ctx context.Context, userID string) context.Context
- func ParseLevelCodes(levelCodes ...string) []string
- func SHA1Hash(b []byte) string
- func SHA1HashString(s string) string
- func Slice2Tree(sliceDatas []map[string]interface{}, idField, pidField string) []map[string]interface{}
- func StructToMap(s interface{}) map[string]interface{}
- func StructsToMapSlice(v interface{}) []map[string]interface{}
- func Trim(s string) string
- type S
- type V
Constants ¶
View Source
const ( // DebugMode 调试模式 DebugMode = "debug" // TestMode 测试模式 TestMode = "test" // ReleaseMode 正式模式 ReleaseMode = "release" // SessionKeyUserID 存储在session中的键(用户ID) SessionKeyUserID = "user_id" // ContextKeyUserID 存储上下文中的键(用户ID) ContextKeyUserID = "user_id" // ContextKeyURLMemo 存储上下文中的键(请求URL说明) ContextKeyURLMemo = "url_memo" // ContextKeyTraceID 存储上下文中的键(跟踪ID) ContextKeyTraceID = "trace_id" )
Variables ¶
View Source
var ( JSONMarshal = json.Marshal JSONUnmarshal = json.Unmarshal JSONMarshalIndent = json.MarshalIndent JSONNewDecoder = json.NewDecoder JSONNewEncoder = json.NewEncoder )
定义JSON操作
View Source
var (
ErrNotFound = errors.New("未找到资源")
)
定义错误
Functions ¶
func ConvertToViewTree ¶
func ConvertToViewTree(treeDatas []map[string]interface{}, labelField, valueField, keyField string) []map[string]interface{}
ConvertToViewTree 转换树形数据为视图树数据
func FromTraceIDContext ¶
FromTraceIDContext 从上下文中获取跟踪ID
func FromUserIDContext ¶
FromUserIDContext 从上下文中获取用户ID
func JSONMarshalToString ¶
func JSONMarshalToString(v interface{}) string
JSONMarshalToString JSON编码为字符串
func NewTraceIDContext ¶
NewTraceIDContext 创建跟踪ID上下文
func NewUserIDContext ¶
NewUserIDContext 创建用户ID上下文
func ParseLevelCodes ¶
ParseLevelCodes 解析分级码(去重)
func Slice2Tree ¶
func Slice2Tree(sliceDatas []map[string]interface{}, idField, pidField string) []map[string]interface{}
Slice2Tree 将切片数据转换为树形数据
func StructsToMapSlice ¶
func StructsToMapSlice(v interface{}) []map[string]interface{}
StructsToMapSlice 将结构体切片转换为字典切片
Types ¶
Click to show internal directories.
Click to hide internal directories.