Skip to content

Instantly share code, notes, and snippets.

Created March 9, 2021 07:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
func printData(c chan *int) {
time.Sleep(time.Second * 3)
data := <-c
fmt.Println("Data in channel is: ", *data)
func main() {
fmt.Println("Main started...")
var a = 10
b := &a
//create channel
c := make(chan *int)
go printData(c)
fmt.Println("Value of b before putting into channel", *b)
c <- b
a = 20
fmt.Println("Updated value of a:", a)
fmt.Println("Updated value of b:", *b)
time.Sleep(time.Second * 2)
fmt.Println("Main ended...")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment