grafov / m3u8

Parser and generator of M3U8-playlists for Apple HLS. Library for Go language. :cinema:
http://tools.ietf.org/html/draft-pantos-http-live-streaming
BSD 3-Clause "New" or "Revised" License
1.23k stars 315 forks source link

Panic when ranging over segments #97

Open kaihendry opened 7 years ago

kaihendry commented 7 years ago

https://play.golang.org/p/hmbq78PZbO

Why is the slice not the same size as the parsed segments of the playlist? How can I tell when I am about to go over the last segment and cause a panic?

Many thanks!

kaihendry commented 7 years ago

Ok, discovered I can check for against nil, but why make it so odd to use?

bradleyfalzon commented 7 years ago

It's probably more of a legacy issue than anything else, we do auto extend now, but just by doubling of size.

To get the count of elements use https://godoc.org/github.com/grafov/m3u8#MediaPlaylist.Count

To loop them I normally check for nil and then break.