Created
January 13, 2019 18:36
-
-
Save ivancorrales/c1eafcec939416e25b5a8582d88034bb to your computer and use it in GitHub Desktop.
This file contains hidden or 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" | |
| "github.com/wesovilabs/koazee" | |
| "koazee-examples-v2/model" | |
| "time" | |
| ) | |
| func main() { | |
| fmt.Println("Print the duration for a given album.") | |
| album := model.Albums[0] | |
| d := koazee.StreamOf(album.Songs). | |
| Reduce(func(duration time.Duration, s *model.Song) time.Duration { | |
| return duration + s.Duration | |
| }).Val() | |
| fmt.Printf("- The duration for album %s by %s is %v\n", album.Title, album.Artist, d) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment