src-d / enry

A faster file programming language detector
https://blog.sourced.tech/post/enry/
Apache License 2.0
460 stars 51 forks source link

cannot find package "github.com/src-d/enry/v2" #241

Closed thevillem closed 5 years ago

thevillem commented 5 years ago

I am trying to install enry for use within my golang script, when grabbing the package I get the following error.

/go # go get github.com/src-d/enry/v2
package github.com/src-d/enry/v2: cannot find package "github.com/src-d/enry/v2" in any of:
        /usr/local/go/src/github.com/src-d/enry/v2 (from $GOROOT)
        /go/src/github.com/src-d/enry/v2 (from $GOPATH)

Here is the output of my go version

/go # go version
go version go1.12.9 linux/amd64

I followed the instructions in #239 , but I am unsure of what I am still doing wrong.

Any guidance would be greatly appreciated.

creachadair commented 5 years ago

Is the /go directory mentioned here a module? It looks like not, but I'm not sure based only on the log output you quoted.

Note that the go get command treats imports differently depending on whether your current working directory is (or is not) inside a module, and whether it's inside $GOPATH. Based on the error message, I think you are probably inside $GOPATH for your system (possibly a container image?) but probably not a module (no go.mod file?)

Please try this, and see if it works:

$ mkdir /tmp/importest ; cd /tmp/importest
$ go mod init importest
$ go get github.com/src-d/enry/v2

If that does work, then it probably means your /go directory is not set up as a module (which would be consistent with a container $GOPATH). Can you say a bit more specifically what you're trying to do?

thevillem commented 5 years ago

Thanks for your quick reply, I made a beginner mistake here and didn't run the go mod init command before running the go get.

After running the init I am able to fetch enry.

creachadair commented 5 years ago

Great, thanks for the update. In that case, I'm going to go ahead and close this issue, but if you have more related troubles please feel free to reopen it.