Thanks to visit codestin.com
Credit goes to github.com

Skip to content

reflect value.Interface not copy for struct #1156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
visualfc opened this issue Sep 24, 2022 · 0 comments · Fixed by #1157
Closed

reflect value.Interface not copy for struct #1156

visualfc opened this issue Sep 24, 2022 · 0 comments · Fixed by #1157

Comments

@visualfc
Copy link
Contributor

demo

package main

import (
	"fmt"
	"reflect"
)

type student struct {
	name string
}

func main() {
	a := []student{student{"A"}, student{"B"}, student{"C"}}
	v := reflect.ValueOf(a)
	i := v.Index(0).Interface()
	a[0] = student{"X"}
	fmt.Println(a, i)
}

go run main.go

[{X} {B} {C}] {A}

gopherjs run main.go

[{X} {B} {C}] {X}
@nevkontakte nevkontakte added this to the Go spec compliance milestone Sep 24, 2022
nevkontakte pushed a commit that referenced this issue Sep 29, 2022
)

* compiler/natives/src/reflect: fix valueIntrface check struct copy

Fixed #1156
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants