Skip to content

Instantly share code, notes, and snippets.

@pote
Created October 20, 2012 13:26
Show Gist options
  • Save pote/3923272 to your computer and use it in GitHub Desktop.
Save pote/3923272 to your computer and use it in GitHub Desktop.
go func() {
for i := 1; i < 100; i++ {
fmt.Println(i)
}
}()
go SomeMotherfuckingExpensiveLoop()
go AnotherMotherfuckingLoop()
// app is keep going here...
var killed channel bool
killed := make(channel bool)
go func() {
<-killed
}
killed <- true
<-time.After(10 * time.Second)
type Jules struct {}
func (jules *Jules) IsStoned() bool {
return false
}
type Vince struct {}
func (vince *Vince) IsStoned() bool {
return true
}
type Stoner interface {
IsStoned() bool
}
func PrintStoner(s Stoner) {
fmt.Printf("%x", s)
}
var x interface{}
func main() {
for i := 0; i < 10; i++ {
fmt.Println(i)
}
}
func main() {
go func() {
for i := 0; i < 10; i++ {
fmt.Println(i)
}
}()
}
func PrintShit() {
for i := 0; i < 10; i++ {
fmt.Println(i)
}
}
func main() {
go PrintShit()
<-time.After(2 * time.Second)
}
func PrintShit(done chan bool) {
for i := 1; i < 10; i++ {
fmt.Println(i)
}
done <- true
}
func main() {
isItThereYet := make(chan bool)
go PrintShit(isItThereYet)
<-isItThereYet
}
func PrintShit() <-chan bool {
done := make(chan bool)
go func() {
for i := 1; i < 10; i++ {
fmt.Println(i)
}
done <- true
}
return done
}
func main() {
<-PrintShit()
}
type Vince struct {
isStoned bool
}
func (vince *Vince) IsStoned() bool {
return vince.isStoned
}
func (vince *Vince) SmokePot() bool {
vince.isStoned = true
}
type FuckingInt int
func (x FuckingInt) Square() int {
return int(x) * int(x)
}
select {
case <-jules.Shoot():
fmt.Println("Jules killed motherfucker")
case <-vince.Shoot():
fmt.Println("Vince killed motherfucker")
}
select {
// *snip*
default:
// do something while waiting for the channels.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment