Goroutines
go someFunc(a, b, c)package main
import "fmt"
func printer(a int){
fmt.Println("a is: ", a)
}
func main(){
fmt.Println("At the start")
for i := 0; i < 10; i++ {
fmt.Println("Sending to routine: ", i)
go printer(i)
}
var get string
fmt.Scanln(&get)
fmt.Println("At the end!")
}
//At the start
//Sending to routine: 0
//Sending to routine: 1
//Sending to routine: 2
//Sending to routine: 3
//Sending to routine: 4
//Sending to routine: 5
//Sending to routine: 6
//Sending to routine: 7
//Sending to routine: 8
//Sending to routine: 9
//a is: 0
//a is: 1
//a is: 2
//a is: 3
//a is: 4
//a is: 5
//a is: 6
//a is: 7
//a is: 8
//a is: 9
//
//At the end!Last updated