As per the Go Memory Model (http://golang.org/ref/mem), the below code
should print "hello, world" twice. But I am not getting any output.
Can anyone let me know what I am missing?
package main
import "sync"
import "fmt"
var a string
var once sync.Once
func setup() {
a = "hello, world"
}
func doprint() {
once.Do(setup)
fmt.Println(a)
}
func twoprint() {
go doprint()
go doprint()
}
func main() {
twoprint()
}
http://play.golang.org/p/7yt6hXIZM4
Thanks
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.