1 Star 0 Fork 20

aiopsxzlinux / gobatis

forked from aurora-engine / gobatis 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
data_type.go 729 Bytes
一键复制 编辑 原始数据 按行查看 历史
aurora.io 提交于 2022-12-06 16:34 . 更新 gobatis 报名
package gobatis
import (
"fmt"
"reflect"
"strings"
)
// TypeKey 通过反射得到一个类型的类型字符串, 适用于普通类型
func TypeKey(t any) string {
return BaseTypeKey(reflect.ValueOf(t))
}
// BaseTypeKey 通过 BaseTypeKey 得到的变量默认全包名对泛型参数进行特殊处理的,不会加上类型中的 [xxx]定义部分信息
func BaseTypeKey(v reflect.Value) string {
baseType := ""
if v.Kind() == reflect.Ptr {
baseType = fmt.Sprintf("%s-%s", v.Type().Elem().PkgPath(), v.Type().String())
} else {
baseType = fmt.Sprintf("%s-%s", v.Type().PkgPath(), v.Type().String())
}
if index := strings.Index(baseType, "["); index != -1 {
baseType = baseType[:index]
}
return baseType
}
Go
1
https://gitee.com/aiopsxzlinux/gobatis.git
git@gitee.com:aiopsxzlinux/gobatis.git
aiopsxzlinux
gobatis
gobatis
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891