package main import ( "fmt" "sync" ) func main() { str := "" strChan := make(chan string) // objMap := make(map[string]string) objStruct := struct{ Text string }{} wg := new(sync.WaitGroup) wg.Add(2) go func() { wg.Done() str = "Hello Wordl 1 Without Chan" strChan <- "Hello Wordl 1 With Chan" // objMap["text"] = "Hello Wordl 1 With Map" objStruct.Text = "Hello Wordl 1 With Struct" }() go func() { wg.Done() str = "Hello Wordl 2 Without Chan" strChan <- "Hello Wordl 2 With Chan" // objMap["text"] = "Hello Wordl 2 With Map" objStruct.Text = "Hello Wordl 2 With Struct" }() wg.Wait() fmt.Println(str) fmt.Println(str) fmt.Printf("\n") fmt.Println(<-strChan) fmt.Println(<-strChan) // fmt.Printf("\n") // fmt.Println(objMap) // fmt.Println(objMap) fmt.Printf("\n") fmt.Println(objStruct.Text) fmt.Println(objStruct.Text) }