Skip to content

Instantly share code, notes, and snippets.

@gsingharoy
Created April 22, 2018 16:44
Show Gist options
  • Save gsingharoy/cc154289368ba2e8fcdce117a2163a4e to your computer and use it in GitHub Desktop.
Save gsingharoy/cc154289368ba2e8fcdce117a2163a4e to your computer and use it in GitHub Desktop.
package main
import "fmt"
func sum(a int, b int, c chan int) {
c <- a + b // send sum to c
}
func main() {
c := make(chan int)
go sum(20, 22, c)
x := <-c // receive from c
fmt.Println(x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment