Dep can't install Algolia's go client?

Hello, I’m trying to install the Algolia go client, and I’m currently experiencing this error :

Solving failure: No versions of github.com/algolia/algoliasearch-client-go met constraints:
v3.5.2: Could not introduce github.com/algolia/algoliasearch-client-go@v3.5.2, as its subpackage github.com/algolia/algoliasearch-client-go does not contain usable Go code (*build.NoGoError).. (Package is required by (root).)
v3.5.1: Could not introduce github.com/algolia/algoliasearch-client-go@v3.5.1, as it is not allowed by constraint ^3.5.2 from project ugram/backend.
... same for each other version

→ dep version  
dep:
 version     : v0.5.4
 build date  : 2019-09-29
 git hash    : 1f7c19e
 go version  : go1.13
 go compiler : gc
 platform    : darwin/amd64
 features    : ImportDuringSolve=false

Here is my Gopkg.toml :

[prune]
  go-tests = true
  unused-packages = true

[[constraint]]
  branch = "v2"
  name = "gopkg.in/mgo.v2"

[[constraint]]
  name = "github.com/algolia/algoliasearch-client-go"
  version = "3.5.2"

Note that I have a different error when I run :

dep ensure -add github.com/algolia/algoliasearch-client-go
Fetching sources...

Solving failure: No versions of github.com/algolia/algoliasearch-client-go met constraints:
    v3.5.2: Could not introduce github.com/algolia/algoliasearch-client-go@v3.5.2 due to multiple problematic subpackages:
    Subpackage github.com/algolia/algoliasearch-client-go does not contain usable Go code (*build.NoGoError).. (Package is required by (root).)     Subpackage github.com/algolia/algoliasearch-client-go/v3 is missing. (Package is required by (root).)
    v3.5.1: Could not introduce github.com/algolia/algoliasearch-client-go@v3.5.1 due to multiple problematic subpackages:
    Subpackage github.com/algolia/algoliasearch-client-go does not contain usable Go code (*build.NoGoError).. (Package is required by (root).)     Subpackage github.com/algolia/algoliasearch-client-go/v3 is missing. (Package is required by (root).)

Thanks by advance

Hello @thomas4,

I’ve been able to reproduce and move a little bit forward but I have no solution as of now.

So first, I’ve tried to create a dummy project within the $GOPATH which imports the Go client v3 as a dependency. By running dep init or manually creating the Gopkg.toml and run dep ensure, I’ve ran into the same issue as you.

Looking at some of the issues from the golang/dep repository (https://github.com/golang/dep/issues/2049, https://github.com/golang/dep/issues/899), it seems like an unsolved issue on their end which may be caused by multiple cases.

As a last resort, I’ve tried to perfom a go get github.com/algolia/algoliasearch-client-go to fetch the Go client in the $GOPATH, which worked. Then, when I ran again dep ensure, I finally got a different error:

v3.5.2: "github.com/algolia/algoliasearch-client-go/algolia/search" imports "github.com/algolia/algoliasearch-client-go/v3/algolia/compression", which contains malformed code: no package exists at "github.com/algolia/algoliasearch-client-go/v3/algolia/compression"

I’ve then checked in both the v3/algolia/search/ and v3/algolia/compression/ but I couldn’t see any issue there (no relative imports, nothing according to the linter, etc.).

I’d recommend you to contact golang/dep maintainers and ask them if there’s any known issue during the dependency resolution regarding packages within Go modules including a major version in their path. This would be my only guess for now.

I don’t know if this is something you’d like to consider but I strongly encourage you to migrate your projects to Go modules. Even though it’s not yet correctly documented, it’s usually a matter of few commands to run. In your case:

go mod init <YOUR_PROJECT_NAME>
go get gopkg.in/mgo.v2
go get github.com/algolia/algoliasearch-client-go/v3@v3.5.2

It has the advantages of working outside your GOPATH and it’s the officially supported (i.e. now standard) dependency management tooling.

Thanks for your time, I will probably migrate to go modules since I’m actually using the version ‘3.0.0-beta05’ as a fallback.

I was using dep only because I read a time ago that go get won’t handle package versions. It seems that it’s solved now :smiley:

Problem solved thanks !