golang利用反射修改结构体字段的值

直接上代码web package main import ( "fmt" "reflect" "testing" ) type B struct { i int64 } func TestReflect(t *testing.T) { x := B{1} b := reflect.ValueOf(&x.i) // 参数必须为指针地址 b.Elem().SetInt(3) fm
相关文章
相关标签/搜索