Created
February 20, 2016 19:01
-
-
Save rooklift/5ae131838138b10ac1f0 to your computer and use it in GitHub Desktop.
Windows didn't like this at all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "time" | |
var finalchan = make(chan time.Time) | |
func chain(n int, in chan time.Time) { | |
var out chan time.Time | |
if n > 0 { | |
out = make(chan time.Time) | |
go chain(n - 1, out) | |
} | |
for { | |
t := <- in | |
if out != nil { | |
out <- t | |
} else { | |
finalchan <- t | |
} | |
} | |
} | |
func main() { | |
out := make(chan time.Time) | |
go chain(1000000, out) | |
out <- time.Now() | |
t := <- finalchan | |
fmt.Println(time.Now().Sub(t)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment