Created
February 15, 2022 21:45
-
-
Save nelhage/bf6c30d34c37cf892ff5cdeb639b9c15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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