diff options
Diffstat (limited to 'src/pkg/reflect/example_test.go')
-rw-r--r-- | src/pkg/reflect/example_test.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/pkg/reflect/example_test.go b/src/pkg/reflect/example_test.go index 62455c00a..cca28eeec 100644 --- a/src/pkg/reflect/example_test.go +++ b/src/pkg/reflect/example_test.go @@ -50,3 +50,17 @@ func ExampleMakeFunc() { // 1 0 // 3.14 2.72 } + +func ExampleStructTag() { + type S struct { + F string `species:"gopher" color:"blue"` + } + + s := S{} + st := reflect.TypeOf(s) + field := st.Field(0) + fmt.Println(field.Tag.Get("color"), field.Tag.Get("species")) + + // Output: + // blue gopher +} |