Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module for path github.com/influxdata/influxdb1-client/v2 #5

Open
akokhanovskyi opened this issue Jan 24, 2019 · 6 comments

Comments

@akokhanovskyi
Copy link

akokhanovskyi commented Jan 24, 2019

Trying to build a go module (using go 1.11) with the InfluxDB client imported throws an error. Here is a snippet to reproduce this:

package main // import "github.com/user/influx"

import "github.com/influxdata/influxdb1-client/v2"

func main() {
	// Do anything with the library
	client.NewHTTPClient(client.HTTPConfig{})
}

Building without modules succeeds:

ak@zonda:/tmp/influx$ go build
ak@zonda:/tmp/influx$ ll
total 6404
drwxrwxr-x  2 ak   ak      4096 Jan 24 19:59 ./
drwxrwxrwt 25 root root   16384 Jan 24 19:59 ../
-rwxrwxr-x  1 ak   ak   6531840 Jan 24 19:59 influx*
-rw-rw-r--  1 ak   ak       191 Jan 24 19:56 main.go

Trying to build a module fails:

ak@zonda:/tmp/influx$ go mod init
go: creating new go.mod: module github.com/user/influx
ak@zonda:/tmp/influx$ go build
go: finding github.com/influxdata/influxdb1-client/v2 latest
go: downloading github.com/influxdata/influxdb1-client/v2 v2.0.0-20190118215656-f8cdb5d5f175
build github.com/user/influx: cannot find module for path github.com/influxdata/influxdb1-client/v2

Any tips? Thanks in advance!

@mark-rushakoff
Copy link
Contributor

If you're creating a new module that depends on this repo, you can explicitly run go get:

$ go build .
go: finding github.com/influxdata/influxdb1-client/v2 latest
go: downloading github.com/influxdata/influxdb1-client/v2 v2.0.0-20190124185755-16c852ea613f
build github.com/x/y: cannot load github.com/influxdata/influxdb1-client/v2: cannot find module providing package github.com/influxdata/influxdb1-client/v2

$ go get github.com/influxdata/influxdb1-client
go: finding github.com/influxdata/influxdb1-client latest
go: downloading github.com/influxdata/influxdb1-client v0.0.0-20190124185755-16c852ea613f
go: extracting github.com/influxdata/influxdb1-client v0.0.0-20190124185755-16c852ea613f

$ go build .

I'll need to circle back with the team to decide what to do about the /v2 name. We'll probably need to keep /v2 for compatibility, but maybe we can alias an existing package to avoid that in the future.

(Based on golang/go#28435 (comment), the Go team's recommendation is that we rename the package.)

@akokhanovskyi
Copy link
Author

akokhanovskyi commented Jan 24, 2019

Thank you, Mark.

Indeed, the "v2" in the package name seems to confuse go build. However, after explicitly running go get and checking in the go.mod file into VSC, there is nothing else required to resolve the problem. Consequent builds are satisfied with the go.mod contents.

I'd also like to use this opportunity to thank you and your team for all the excellent work.

Cheers!

@andig
Copy link

andig commented Feb 15, 2019

I believe what's confusing go guild is that the v2 in go modules syntax should be a release rather than it's own subtree in the source code? It might make sense to check this behaviour with the go team.

@orourkedd
Copy link

I ended up just forking the repo and converting it to a go module: https://github.com/orourkedd/influxdb1-client

My go.mod entry looks like this:
require github.com/orourkedd/influxdb1-client v0.0.0-20190326200226-bd3b72602b58

And my import statement look like this:
import "github.com/orourkedd/influxdb1-client/client"

toomasp pushed a commit to toomasp/influxdb1-client that referenced this issue May 23, 2019
@kmansoft
Copy link

I ended up just forking the repo and converting it to a go module: https://github.com/orourkedd/influxdb1-client

Works, thanks!

@Seirdy
Copy link

Seirdy commented Aug 14, 2019

This appears to be fixed if you use the solution presented in the README, added in fc22c7d.

Just import like this:

import (
	_ "github.com/influxdata/influxdb1-client"
	client "github.com/influxdata/influxdb1-client/v2"
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants