Files
learngo/30-concurrency/xxx-concurrent-downloader/fetch/drain.go
2019-04-27 20:18:24 +03:00

13 lines
277 B
Go

package fetch
// Drain drains the progress updates and returns the latest progresses
func Drain(updates <-chan Progress) map[string]Progress {
latest := make(map[string]Progress)
// save the latest progress
for p := range updates {
latest[p.URL] = p
}
return latest
}