Usage of go routine in Go

In Go Lang, you can achieve the concurrency using go routine. you have to declare "go" in front of a function call. We have added sleep in main go routine. Other wise main routine will finish the execution and we are not able see the new printHello go routine output. We can avoid sleep by Channel.

package main

import (  

func printHello() {  
    fmt.Println("Go routine example")
func main() {  
    go printHello()
    time.Sleep(1 * time.Second)
    fmt.Println("main function")

Go routine example
main function