Closed
Description
- main.go
package main
import (
"fmt"
"reflect"
)
func main() {
c := &A{}
c.value = true
c.point = Point{100, 200}
in := reflect.ValueOf(c).Elem()
v := reflect.New(in.Type())
e := v.Elem()
f0 := e.Field(0)
e.Set(in)
fmt.Println(e.Field(0), f0, e.Field(0) == f0)
}
type Point struct {
x int
y int
}
type Embed struct {
value bool
point Point
}
type A struct {
Embed
}
- go run main.go
{true {100 200}} {true {100 200}} true
- gopherjs run main.go
{true {100 200}} {false {0 0}} false
reflect.Value.Set error no sync with embed field.
Metadata
Metadata
Assignees
Labels
No labels