Skip to content

Instantly share code, notes, and snippets.

@Moddus
Last active August 29, 2015 14:20
Show Gist options
  • Save Moddus/441235bca961f6059d8a to your computer and use it in GitHub Desktop.
Save Moddus/441235bca961f6059d8a to your computer and use it in GitHub Desktop.
Just some golang snipptes
package main
import (
"log"
)
func main() {
c := make(chan string)
for i := 0; i < 10; i++ {
go func(i int, c chan string) {
log.Println(i)
c <- ""
}(i, c)
}
for i:= 0; i < 10; i++ {
<- c
}
}
package main
import (
"log"
"sync"
)
func main() {
var wg sync.WaitGroup
for i := 0; i < 10; i++ {
wg.Add(1)
go func(i int) {
defer wg.Done()
log.Println(i)
}(i)
}
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment