Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

...