Correct usage of Google Api Client

52 views
Skip to first unread message

Mikhail Ladonkin

unread,
Nov 8, 2021, 12:59:31 PM11/8/21
to golang-nuts
Hi,

I'm new to Golang so sorry if the question seems stupid.

I'm trying to inform google about a new job on my website using the following documentation - https://developers.google.com/search/apis/indexing-api/v3/prereqs

At the end of the page they provide the instructions of how to do it using different languages, but unfortunately not with Go. I found the following library - https://github.com/googleapis/google-api-go-client - which seems to be right for the task but I'm not sure how to use it properly - all I came up with is:

ctx := context.Background()
indexingService, err := indexing.NewService(ctx)

But I don't know how to send the request or how to include the body into it (and I'm not sure about the part that I wrote as well, to be honest).

Maybe someone has already had some experience with it and can point me to the right direction?

Sean Liao

unread,
Nov 8, 2021, 1:36:04 PM11/8/21
to golang-nuts
svc, err := indexing.NewService()
res, err := svc.UrlNotifications.Publish(&indexing.UrlNotification{ /* things in here */ }).Do()

Mikhail Ladonkin

unread,
Nov 8, 2021, 2:02:28 PM11/8/21
to golang-nuts
Thanks a lot! Have a good day!

понедельник, 8 ноября 2021 г. в 21:36:04 UTC+3, seank...@gmail.com:
Reply all
Reply to author
Forward
0 new messages