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

Migrate to Go Modules #363

Closed
wants to merge 1 commit into from

Conversation

marwan-at-work
Copy link

This PR migrates the package to Go Modules and updates the path according to Semantic Import Versioning

Generated by https://github.com/marwan-at-work/mod

@garyburd
Copy link
Member

garyburd commented Sep 5, 2018

This PR breaks compatibility with Go 1.8 and below.

@marwan-at-work
Copy link
Author

@garyburd yes, totally up to you if you'd like to accept that or not :)

@garyburd
Copy link
Member

garyburd commented Sep 5, 2018

Is there a way to add Go module support and retain backwards compatibility with older versions of Go?

@marwan-at-work
Copy link
Author

@garyburd go 1.9.X and 1.10.X (x being latest) are backwards compatible. They can still import your library without the vX suffix. But otherwise, 1.8 won't work unless you copy and paste the code into a vX directory (or type alias things there) which is not a fun thing to do.

@elithrar
Copy link

elithrar commented Sep 5, 2018

Go 1.9 was released in August 2017 - only 1 year ago. Since modules are only "experimental" in Go 1.11, we could hold off until Go 1.12 (when they are first-class), which is scheduled for Jan 2019.

Packages that declared a >= v2.x on the "vanilla" import path are effectively incompatible with modules. I believe @natefinch ran into this with mage and @markbates with Buffalo.

@natefinch
Copy link

yeah, so I was actually wrong.... with the latest patch of 1.9 and 1.10, those tools understand how to read go.mod... so if your code is on v2, but your import path doesn't include v2.... the go tool will figure it out if you put

module github.com/foo/bar/v2 

in the go.mod, and it'll use the v2 branch of the repo.

At least, that's what I've been told by reliable sources.

@natefinch
Copy link

(but also if you want to be compatible with go 1.8 or earlier, you need a physical /v2 folder, because those tools weren't updated to read the go.mod and don't know)

What I'd do: try it out before merging.

@garyburd
Copy link
Member

garyburd commented Sep 5, 2018

What are the downsides of not migrating to Go Modules?

@marwan-at-work
Copy link
Author

@garyburd for redigo not much.

The upside from introducing Go Modules is that the Go Command now recognizes your dependencies and can resolve them appropriately when users use redigo in their own systems. But since redigo does not have any dependencies it seems like, then you're fine.

Another one, is that it's just a migration thing. Which can wait until 1.12 :)

@bjm88
Copy link

bjm88 commented Sep 23, 2018

I would vote to do it, if I recall a referenced import path/module got renamed on this project and it broke being able to use it briefly. I believe things like that wouldn't happen in the go 1.11 world. Its been a long time coming that go needed a proper module management tool standard. From what I've seen after some grumbling, the community is getting behind vgo's integration and seems very useful. It also better supports monolithic repos that are totally mixed tech stacks and outside GOPATH, death to GOPATH dependence is good.

@garyburd
Copy link
Member

garyburd commented Sep 25, 2018

@bjm88 Importers using Go 1.8 and below will vote against this PR.

To all: Will this work?

  • Remove redigo/internal by copying what's needed to redigo/redis and redigo/redisx.
  • Remove the import comment from the package declaration.
  • Update _test.go and redigo/redisx files to import github.com/gomodulue/redigo/v2/redis instead of github.com/gomodule/redis. Use build tags to disable these files on Go 1.8 and below.
  • Add the go.mod file.

With this change, redisx and some tests are lost on Go 1.8 and below, but redigo/redis will continue to work.

@marwan-at-work
Copy link
Author

marwan-at-work commented Sep 25, 2018

@garyburd as another option: is it acceptable for users of 1.8 and below to simply stick to the current major version of redigo until they are ready to migrate Go 1.8 to 1.9 or above?

@garyburd
Copy link
Member

It is not acceptable to require users to change how they fetch the code for this package. This includes Go 1.8 users who fetch the package using go get.

I want feedback from Go module experts on my proposal above.

@garyburd garyburd mentioned this pull request Sep 25, 2018
@garyburd
Copy link
Member

Let's continue discussion in #366.

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

Successfully merging this pull request may close these issues.

None yet

5 participants