Skip to content

Instantly share code, notes, and snippets.

@Imater
Created August 25, 2014 10:02
Show Gist options
  • Save Imater/1200a7abf5707704b6fc to your computer and use it in GitHub Desktop.
Save Imater/1200a7abf5707704b6fc to your computer and use it in GitHub Desktop.
waterfall in go
package main
import (
"fmt"
"time"
"strconv"
)
func getFio () chan int {
c := make(chan int)
go func (){
time.Sleep(time.Second*2)
c <- 23
}()
return c
}
func getTax (id int) chan string{
c := make(chan string)
time.Sleep(time.Second*4)
go func (){
c <- "Tax for user " + strconv.Itoa(id) + " is " + strconv.Itoa(id*2)
}()
return c
}
func main (){
id := getFio()
fmt.Println(<-getTax(<-id))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment