Created
March 6, 2018 13:05
-
-
Save ethe/5dd953129d9599412eddf637fd1f0039 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 | |
| type S struct { | |
| Inner int | |
| } | |
| func main() { | |
| foo() | |
| } | |
| func foo() { | |
| ch := make(chan *S, 256) | |
| go bar(ch) | |
| for { | |
| s := &S{Inner: 1} | |
| ch <- s | |
| (*s).Inner = 2 | |
| } | |
| } | |
| func bar(ch chan *S) { | |
| for s := range ch { | |
| s := s | |
| println(s.Inner) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment