Created
April 4, 2016 21:56
-
-
Save lexszero/ac84f0a6e19760c018ad6147cf233d65 to your computer and use it in GitHub Desktop.
stdin
This file contains 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
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