Skip to content

Instantly share code, notes, and snippets.

@aj0strow
Created September 7, 2018 17: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 aj0strow/7cb847e8ddc9c20b3d42738329314d1a to your computer and use it in GitHub Desktop.
Save aj0strow/7cb847e8ddc9c20b3d42738329314d1a to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
type whyNeedPointer struct {
Do func(string)
}
func main() {
doStuff := func(s string) {
fmt.Println(s)
}
w := whyNeedPointer{
Do: doStuff,
}
w.Do("why need ptr?")
nextDo := make(chan func(string))
go func() {
nextDo <- func(s string) {
fmt.Printf("next %s\n", s)
}
}()
w.Do = <-nextDo
w.Do("time no use ptr")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment