zmb3 / spotify

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

Consuming AddTracksToPlaylist with multiple IDs not compiling #135

Closed PaulIvanov closed 3 years ago

PaulIvanov commented 3 years ago

When I attempt to use func (c *Client) AddTracksToPlaylist(playlistID ID, trackIDs ...ID) on the client. My compiler fails with the following error: cannot use myArr (type []spotify.ID) as type spotify.ID in argument to client.AddTracksToPlaylist

Maybe this is an oversight on my part, but is there a certain type I need to be using besides an array or slice for this?

zmb3 commented 3 years ago

If you're trying to pass a slice into a variadic method like that you need to append a ...

So

AddTrackToPlaylist(id, myArr...)
PaulIvanov commented 3 years ago

Thanks for the quick reply, I knew it had to be something I was doing wrong. I had never learned of variadic functions in golang yet. Thank!