You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
reflect.Value.Set error no sync with embed field.
The text was updated successfully, but these errors were encountered: