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

No go.mod in release-branch.v6 #1112

Closed
basvandijk opened this issue Jun 6, 2019 · 5 comments
Closed

No go.mod in release-branch.v6 #1112

basvandijk opened this issue Jun 6, 2019 · 5 comments

Comments

@basvandijk
Copy link
Contributor

Which version of Elastic are you using?

[ ] elastic.v7 (for Elasticsearch 7.x)
[x] elastic.v6 (for Elasticsearch 6.x)
[ ] elastic.v5 (for Elasticsearch 5.x)
[ ] elastic.v3 (for Elasticsearch 2.x)
[ ] elastic.v2 (for Elasticsearch 1.x)

Please describe the expected behavior

I see that both branch release-branch.v5 and release-branch.v7 have a go.mod file.

It would be nice if release-branch.v6 also had a go.mod file.

That way I should be able to import the library directly from GitHub using:

import (
	elastic5 "github.com/olivere/elastic/v5"
	elastic6 "github.com/olivere/elastic/v6"
	elastic7 "github.com/olivere/elastic/v7"
)

instead of importing from gopkg.in/olivere/elastic.v*. This is needed when developing against an unreleased version.

@olivere
Copy link
Owner

olivere commented Jun 6, 2019

Although that's the obvious way to do it, I have refrained from doing so until now. I was an early adopter of Go modules with v6, and it caused a lot of problems to users (see e.g. #877). So I decided to not introduce Go modules to v6 and delay that until v7. I'm confused about v5 having a go.mod. That looks like a bug to me.

@basvandijk
Copy link
Contributor Author

Ok I see. I'm new to Go and its ecosystem. Are Go modules more established now? If so, maybe elastic could standardise on it now.

@olivere
Copy link
Owner

olivere commented Jun 6, 2019

Yes, they are. We could very simply upgrade to Go modules now. But that would break all existing v6 clients when they update; backwards compatibility is more important to me than using Go modules, so I won't do that.

If you use Go modules within your project, you should be able to use all three versions in the same project—in parallel—even if they don't use Go modules. The import paths don't look too nice, but that's all there is:

import (
	elastic5 "gopkg.in/olivere/elastic.v5"
	elastic6 "github.com/olivere/elastic"
	elastic7 "github.com/olivere/elastic/v7"
)

@basvandijk
Copy link
Contributor Author

Definitely agree about backwards compatibility.

The reason I wanted to use the GitHub-based URLs was so I could import a specific revision from GitHub. However I just discovered I can also do this with the gopkg.in URLs, as in:

require (
        ...
        gopkg.in/olivere/elastic.v6 v6.2.19-0.20190606093138-f7db55b7060d
        ...
)

So I guess I don't need a go.mod in v6 and I'll close this issue.

Context: I'm working on the following PR: phillbaker/terraform-provider-elasticsearch#27

@olivere
Copy link
Owner

olivere commented Jun 6, 2019

Definitely agree about backwards compatibility.

The reason I wanted to use the GitHub-based URLs was so I could import a specific revision from GitHub. However I just discovered I can also do this with the gopkg.in URLs, as in:

require (
        ...
        gopkg.in/olivere/elastic.v6 v6.2.19-0.20190606093138-f7db55b7060d
        ...
)

So I guess I don't need a go.mod in v6 and I'll close this issue.

Context: I'm working on the following PR: phillbaker/terraform-provider-elasticsearch#27

No. You must not use that import path for v6. You should use the import paths as stated in the README.

The reason is because v6 will import other parts of the library, like github.com/olivere/elastic/uritemplates, so you end up with a mix of gopkg.in/olivere/elastic.v6 as well as github.com/olivere/elastic... something you really don't want, trust me.

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

2 participants