lab002

command
v0.0.0-...-f10d331 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 2 Imported by: 0

README

example02,总结play009(读取)

注意点

  • reflect.Type,和类型相关的都在这个里面找,比如有多少个字段,字段名称,字段类型是什么
  • reflect.Value,和值相关的用这个。比如这个字段的值是多少
  • struct和pointer在使用reflect的时候是不一样的。FieldByName()只能在struct使用。pointer的时候要用Elem()
  • ValueType才有Kind()方法,StructField是没有的

运行结果

Imgur

参考资料

  1. http://www.jianshu.com/p/0d346577d32f
  2. https://github.com/liguoqinjim/go-playground/tree/master/play009

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL