Files
moxa/_test/struct58.go
2020-09-29 09:22:04 +02:00

25 lines
245 B
Go

package main
import (
"fmt"
"reflect"
)
type A struct {
Test string `tag:"test"`
}
func main() {
a := A{}
t := reflect.TypeOf(a)
f, ok := t.FieldByName("Test")
if !ok {
return
}
fmt.Println(f.Tag.Get("tag"))
}
// Output:
// test