func getPlaylist(client *spotify.Client, user *spotify.PrivateUser, playlistName string) (*spotify.SimplePlaylist, error) { page, err := client.CurrentUsersPlaylists() if err != nil { return nil, err } for _, playlist := range page.Playlists { if playlist.Name == playlistName { log.Printf("Found playlist: %v", playlistName) return &playlist, nil } } // otherwise create a new playlist for the user log.Printf("Creating playlist: %v", playlistName) playlist, err := client.CreatePlaylistForUser(user.ID, playlistName, true) return &playlist.SimplePlaylist, err }