github.com/golang-infrastructure/go-reflect-utils@v0.0.0-20221130143747-965ef2eb09c3/tag.go (about) 1 package reflect_utils 2 // 3 //import "reflect" 4 // 5 //// 解析tag 6 // 7 //const DefaultTagPattern = "ItemName:key=value," 8 // 9 //// StructFieldTag 表示解析到的一个Struct的Field的标签信息 10 //type StructFieldTag struct { 11 // FieldType reflect.Type 12 // FieldValue reflect.Value 13 // FieldTagItemMap map[string]TagItem 14 //} 15 // 16 //type TagItem struct { 17 // ItemName string 18 // ItemValue string 19 // SubItemKeyValueMap map[string]string 20 //} 21 // 22 //func (x *TagItem) Contains(name string) bool { 23 // _, exists := x.SubItemKeyValueMap[name] 24 // return exists 25 //} 26 // 27 //func (x *TagItem) Get(name string) string { 28 // 29 //} 30 // 31 //func (x *TagItem) GetAsBool(name string) bool{ 32 // 33 //} 34 // 35 //func (x *TagItem) GetAsInt() { 36 // 37 //} 38 // 39 //func (x *TagItem) GetAsFloat64() { 40 // 41 //} 42 // 43 //func (x *TagItem) GetAsFloat32() { 44 // 45 //} 46 // 47 //func (x *TagItem) GetOrDefault() { 48 // 49 //} 50 // 51 //func (x *TagItem) Lookup() { 52 // 53 //} 54 // 55 //// ParseTag 解析Struct字段上的TAG 56 //func ParseStructTag(structValue any) { 57 // reflectType := reflect.TypeOf(structValue) 58 // reflectType.Field(0).Tag 59 // reflectValue := reflect.ValueOf(structValue) 60 // 61 //} 62 // 63 //func ParseTag(tagStr string) { 64 // 65 //}