Skip to content

Instantly share code, notes, and snippets.

@nelhage
Created February 15, 2022 21:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nelhage/bf6c30d34c37cf892ff5cdeb639b9c15 to your computer and use it in GitHub Desktop.
Save nelhage/bf6c30d34c37cf892ff5cdeb639b9c15 to your computer and use it in GitHub Desktop.
package main
var x interface{ f() }
type A struct {
fp func()
}
func (a A) f() { a.fp() }
type B struct {
i uint64
}
func (b B) f() {}
func main() {
x = A{fp: func() {}}
done := make(chan struct{})
go func() {
for i := 0; i < 1_000_000; i++ {
x.f()
}
done <- struct{}{}
}()
go func() {
for {
x = A{fp: func() {}}
x.f()
x = B{i: 0xaaaaaaaaaaaaaaaa}
x.f()
}
}()
<-done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment