From f28caaded6cba0559ba4ed79a9521416c8ea8a55 Mon Sep 17 00:00:00 2001 From: Soham Ghugare Date: Thu, 28 Mar 2024 09:50:53 +0530 Subject: [PATCH] chore: updated deprecated methods for creating new service --- go/search_by_keyword.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/go/search_by_keyword.go b/go/search_by_keyword.go index 3c8f0b64..8a19714a 100644 --- a/go/search_by_keyword.go +++ b/go/search_by_keyword.go @@ -4,9 +4,9 @@ import ( "flag" "fmt" "log" - "net/http" - "google.golang.org/api/googleapi/transport" + "golang.org/x/net/context" + "google.golang.org/api/option" "google.golang.org/api/youtube/v3" ) @@ -20,11 +20,7 @@ const developerKey = "YOUR DEVELOPER KEY" func main() { flag.Parse() - client := &http.Client{ - Transport: &transport.APIKey{Key: developerKey}, - } - - service, err := youtube.New(client) + service, err := youtube.NewService(context.Background(), option.WithAPIKey(developerKey)) if err != nil { log.Fatalf("Error creating new YouTube client: %v", err) }