SHOW:
|
|
- or go back to the newest paste.
| 1 | type TestStruct struct {
| |
| 2 | TestString string | |
| 3 | } | |
| 4 | ||
| 5 | func Test(i interface{}) {
| |
| 6 | - | // Remake i to a TestStruct again |
| 6 | + | newObjPntr := reflect.New(reflect.TypeOf(i)) |
| 7 | newObj := reflect..Interface(newObjPntr) | |
| 8 | ||
| 9 | newObj.TestString = "testar" | |
| 10 | } | |
| 11 | ||
| 12 | func main() {
| |
| 13 | ||
| 14 | Test(new(TestStruct)) | |
| 15 | } |