Go Reflection是程序检查其自身结构(尤其是通过类型)的能力。这是元编程的一种形式。
反射可用于在运行时调查类型和变量, 例如它的大小, 方法, 也可以“动态”地称这些方法。
去反映的例子
package main
import(
"fmt"
"reflect"
)
func main() {
age := 27.5
fmt.Printf("%T\n" , age)
fmt.Println(reflect.TypeOf(age))
}
输出:
float64
float64
微信公众号
手机浏览(小程序)
Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(): Failed to enable crypto in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57
Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_50033.jpg): failed to open stream: operation failed in
/mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line
57