Skip to content

Instantly share code, notes, and snippets.

@lexszero
Created April 4, 2016 21:56
Show Gist options
  • Save lexszero/ac84f0a6e19760c018ad6147cf233d65 to your computer and use it in GitHub Desktop.
Save lexszero/ac84f0a6e19760c018ad6147cf233d65 to your computer and use it in GitHub Desktop.
stdin
type Huita struct {
v string
cb chan HuitaCmd
stop chan bool
}
func NewHuita() *Huita {
h := &Huita{
cb: make(chan HuitaCmd),
stop: make(chan bool),
}
go func() {
for {
select {
case cb := <-h.cb:
cb(h)
case <-stop:
return
}
}
}()
return h
}
func (h *Huita) Fuck() string {
r := make(chan string)
c <- func(h *Huita) {
h.v = "Fuck you"
r <- h.v
}
return <-r
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment