Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chaudharisuresh997/055a56f81c8756b534adc81796fdb0c0 to your computer and use it in GitHub Desktop.
Save chaudharisuresh997/055a56f81c8756b534adc81796fdb0c0 to your computer and use it in GitHub Desktop.
Channel and Waitgroup example
package main
import (
"fmt"
"sync"
)
//Workgroup example
func tie(wg *sync.WaitGroup) {
fmt.Println("Shiv")
wg.Done()
}
//channel
func chanFunc(ch chan int) {
fmt.Println("chValue")
defer close(ch)
ch <- 1
}
func main() {
// var wg sync.WaitGroup
// wg.Add(1)
// go tie(&wg)
// wg.Wait()
//channel
ch := make(chan int)
go chanFunc(ch)
fmt.Println(<-ch)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment