...
Code Block |
---|
package main import ( "fmt" ) func main(){ i := 7 inc(&i) fmt.Println(i) } func inc(x *int) { *x++ } |
Concurrency
Go supports concurency by the use of the go command
Code Block |
---|
package main
import (
"fmt"
)
func main(){
//run in background
go count("sheep")
count("fish")
}
func count(thing string) {
for i:=0; true; i++ {
fmt.Println(i, thing)
time.Sleep(time.Millisecond * 500)
}
} |
References
Reference | URL |
---|---|
Learn Go in 12 Minutes | https://www.youtube.com/watch?v=C8LgvuEBraI |
Go Packages | https://golang.org/pkg/ |
Go By Examples | https://gobyexample.com/ |
...