-
Notifications
You must be signed in to change notification settings - Fork 570
Apparently simple program fails to behave like native #262
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
Comments
Hi @FiloSottile (I know you from Twitter and I'm a big fan of your work and use of Go!), At first I was going to say this is likely because that However, I don't think that's the problem. I think you're right and there may be sort of bug with GopherJS channel support. I've traced the program both via Which causes the two executions to return different results: The full log files are here: Edit: Actually, there are goroutines involved so exact order of execution may vary (it's a flattened log) and therefore the actual difference in behavior is smaller than the text diff may suggest. But there are still some differences, like the first This is definitely worth looking into and fixing, and the good news is that I think it's likely that GopherJS will soon be able to run this code successfully. Thanks for the bug report! |
I've made a minimal reproducible test case for the issue: package main
import "fmt"
type T struct{ string }
func main() {
c := make(chan T)
go foo(c)
fmt.Println(<-c)
}
func foo(c chan T) {
var t T
t.string = "Original"
c <- t
t.string = "Modified After Sending"
} Expected outcome (and actual output for
Whereas GopherJS output is:
http://www.gopherjs.org/playground/#/glD7xks6KD I have a guess the issue might be very trivial, when sending on a channel, the value should be copied, rather than original being used. |
Yes, we have to explicitly copy the values in JS. Sorry for the trouble and thanks for reporting! |
@shurcooL btw: Thanks for investigating and the test case. Because of that, I immediately knew what was wrong and how to fix it. Much appreciated. |
Here's a small program
I compile it with default options and load it in a empty page, and then from the console:
The parser fails in some weird way. Different inputs fail in different ways.
Here's a equivalent program, that I run with
go run
First time gopherjs user, so I might be missing something, but it looks like a bug in the channel usage of
dns.ReadRR
(source)The text was updated successfully, but these errors were encountered: