草庐IT

controllerStruct

全部标签

Golang 使用反射设置结构字段

我目前正在做以下事情funcTest(controllerinterface{}){controllerType:=reflect.TypeOf(controller)controllerFunc:=reflect.ValueOf(controller)controllerStruct:=reflect.New(controllerType.In(0))fori:=0;i使用下面的函数调用Test(controllers.Test.IsWorking)typeTeststruct{NamestringH*Hello}typeHellostruct{Friendstring}func(t

Golang 使用反射设置结构字段

我目前正在做以下事情funcTest(controllerinterface{}){controllerType:=reflect.TypeOf(controller)controllerFunc:=reflect.ValueOf(controller)controllerStruct:=reflect.New(controllerType.In(0))fori:=0;i使用下面的函数调用Test(controllers.Test.IsWorking)typeTeststruct{NamestringH*Hello}typeHellostruct{Friendstring}func(t