From b40144b75b0b5c32176d15a9b34eb3aa34a7a8be Mon Sep 17 00:00:00 2001 From: Yaakov Yosef Miller Date: Thu, 25 Jan 2024 12:49:00 -0500 Subject: [PATCH] deprecated code fix client Fix for deprecated functions --- go/search_by_keyword.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/go/search_by_keyword.go b/go/search_by_keyword.go index 3c8f0b64..fd76b43a 100644 --- a/go/search_by_keyword.go +++ b/go/search_by_keyword.go @@ -18,19 +18,14 @@ var ( const developerKey = "YOUR DEVELOPER KEY" func main() { - flag.Parse() - - client := &http.Client{ - Transport: &transport.APIKey{Key: developerKey}, - } - - service, err := youtube.New(client) + ctx := context.Background() + service, err := youtube.NewService(ctx, option.WithAPIKey(developerKey)) if err != nil { log.Fatalf("Error creating new YouTube client: %v", err) } // Make the API call to YouTube. - call := service.Search.List("id,snippet"). + call := service.Search.List([]string{"id", "snippet"}). Q(*query). MaxResults(*maxResults) response, err := call.Do()