Tuesday, December 4, 2018

Sample Go Code

package main

import (
	"fmt"
	"time"
)

func say(s string) {
	for i := 0; i < 5; i++ {
		time.Sleep(100 * time.Millisecond)
		fmt.Println(s)
	}
}

func main() {
    say("world")
    go say("hello")
    // say("abcd")
}

  • Why hello does not get printed?

Written with StackEdit.

No comments:

Post a Comment