Skip to content

Instantly share code, notes, and snippets.

@ethe
Created March 6, 2018 13:05
Show Gist options
  • Select an option

  • Save ethe/5dd953129d9599412eddf637fd1f0039 to your computer and use it in GitHub Desktop.

Select an option

Save ethe/5dd953129d9599412eddf637fd1f0039 to your computer and use it in GitHub Desktop.
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