zmb3 / spotify

A Go wrapper for the Spotify Web API
Apache License 2.0
1.34k stars 284 forks source link

GetArtistAlbums panics #120

Closed pixelrazor closed 4 years ago

pixelrazor commented 4 years ago

GetArtistAlbums(id) will call return c.GetArtistAlbumsOpt(artistID, nil, nil) The third arg should not be supplied.

func (c *Client) GetArtistAlbumsOpt(artistID ID, options *Options, ts ...*AlbumType) (*SimpleAlbumPage, error) {
    spotifyURL := fmt.Sprintf("%sartists/%s/albums", c.baseURL, artistID)
    // add optional query string if options were specified
    values := url.Values{}
    if ts != nil {
        types := make([]string, len(ts))
        for i := range ts {
            types[i] = ts[i].encode()
        }
        values.Set("include_groups", strings.Join(types, ","))
    }

that for loops panics, since ts will not be nill, but will instead be [nil]