首页 > 其他 > 详细

go struct 自定义标签获取

时间:2019-05-22 19:32:23      阅读:138      评论:0      收藏:0      [点我收藏+]
package main

import (
"fmt"
"reflect"
)

type Test struct {
Id int `json:"user_id"`
Name string "this is name"
}

func main() {
t := Test{Id: 1, Name: "xiaochuan"}
r := reflect.TypeOf(t)

fmt.Println()
fmt.Printf("Id Tag is %s \n", r.Field(0).Tag)
fmt.Println()
fmt.Printf("Name Tag is %s \n", r.Field(1).Tag)
}

 

go struct 自定义标签获取

原文:https://www.cnblogs.com/mafeng/p/10907494.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!