Skip to content

Instantly share code, notes, and snippets.

@ivancorrales
Created January 13, 2019 18:36
Show Gist options
  • Select an option

  • Save ivancorrales/c1eafcec939416e25b5a8582d88034bb to your computer and use it in GitHub Desktop.

Select an option

Save ivancorrales/c1eafcec939416e25b5a8582d88034bb to your computer and use it in GitHub Desktop.
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