Alogolia API and GO 1.11

Hello
I want to write a Google cloud function in GO that calls ALGOLIA for a search. GCF only supports GO 1.11.5 for now. I wrote a little test program:

main package

import (
** “Fmt”**
** “os”**

** “github.com/algolia/algoliasearch-client-go/algolia/search”**
)

func main () {
client: = search.NewClient (“xxxxxxxxxx”, “xxxxxxxxxxxxxxxxxxxxxx”)
index: = client.InitIndex (“Match”)

res, err: = index.Search (“andy”)
if err! = nil {
fmt.Println (err)
os.Exit (1)
}

fmt.Println (err)
}

But when I try to build or execute it, I have a mistake that the ALGOLIA modules need GO 1.12:

go build github.com/algolia/algoliasearch-client-go/algolia/call: module requires Go 1.12
go build github.com/algolia/algoliasearch-client-go/algolia/iterator: module requires Go 1.12
go build github.com/algolia/algoliasearch-client-go/algolia/rand: module requires Go 1.12
go build github.com/algolia/algoliasearch-client-go/algolia/errs: module requires Go 1.12
go build github.com/algolia/algoliasearch-client-go/algolia/wait: module requires Go 1.12
go build github.com/algolia/algoliasearch-client-go/algolia/debug: module requires Go 1.12

My go.mod file is :
xxx.fr/yyy module

require github.com/algolia/algoliasearch-client-go v0.0.0-20190708092936-b506e86cf5a8

I use Visual studio code as IDE.

Yet the documentation says that GO APIs are compatible with versions 1.8 and above.

How to solve this problem.

Regards

Hello @jmdollat,

Thank you for your question and sorry for the inconvenience it may have caused.

The Go API client is indeed working with Go modules (prior to Go 1.12) or with the dep dependency manager, as you may see from our Travis test runner.

The issue you encounter seems to be related to the way the Go modules are fetched. Thanks to the code snippet you sent (thank you for taking the time to provide it to us), I was able to reproduce within a Docker container running Go 1.11 as well. Here are the steps I’ve followed:

mkdir tmp
cd tmp

# here, I've copied/pasted your code snippet as main.go

go mod init tmp
go get github.com/algolia/algolialsearch-client-go@v3.1.0
go run main.go

# At this point, your program was working (I just needed to change the
# last `fmt.Println(err)` into `fmt.Println(res)` to avoid the `res declared
# and not used` error.

Let me know if your procedure is the same but differs in term of result.

Best regards,