-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
add go.mod, assuming current master is a v3 branch #327
Conversation
Import paths are changed according to Semantic Import Versions rationale. Otherwise `vgo test ./middleware` fails bacause of import path interpretation - it assumes that "github.com/go-chi/chi" points to v1, fails to find some public functions from v3 and dies. As semantic import versioning seems to be the official way, we should respect it. This is an experimental way of implementing go-chi#302 without major version bump. Backwards compatibility is done via `v3` symlink - old go is OK with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The direction of this PR looks good to me.
However, I'm not a big fan of having to change the import paths everywhere to the /v3
suffix. It affects the middleware subpkg too, as seen in the changeset. We need to be VERY careful not to break existing go ecosystem that is not aware of Go modules -- can they still use this project "as is" without the "/v3" suffix?
- "github.com/go-chi/chi"
+ "github.com/go-chi/chi/v3"
The "v3" directory symlink hack may not work for everyone. Or is that a recommended approach for the v2+ projects that are adopting vgo?
@@ -0,0 +1 @@ | |||
. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this a symlink, right?
it's a nice hack .. but does this work outside of Unix at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap, it's a symlink.
Unfortunately, I don't have Windows to check. But I bet it doesn't work on Windows.
Anyway, the official approach is to use go 1.9.7+ or go 1.10.3+ and drop support of older versions.
And with this symlink we give Unix users with older go versions a chance to keep using it for a while.
As you can see, CI with go 1.7.x and 1.8.x passed successfully
|
||
require ( | ||
golang.org/x/net v0.0.0-20180611182652-db08ff08e862 | ||
golang.org/x/text v0.3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we use golang.org/x/text ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's used in golang.org/x/net
undercover, for Unicode support.
golang.org/x/net
haven't adopted go.mod yet, so golang.org/x/text
resolving appears here.
As soon as go.mod is introduced in golang.org/x/net
and you update it, transitive dependency will go away automatically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that sounds good to me.
@VojtechVitek The latest point releases of go (1.10.3 and 1.9.7) can work with |
@cskr I don't think we want to bump to v4.0 just because of vgo :) we gotta figure this out, or let the Go authors know that vgo sucks I tried a while ago.. see golang/go#25967 btw: We can't assume people upgraded to go 1.10.3 and 1.9.7 .. we have to be backward compatible with older versions. |
Yeap, pre-go1.9.7 versions can use the project "as is", if they are on Unix, as commented above. I don't see a quick-win way for Windows users though.
No, the only recommended approach I've seen yet is to use go1.9.7+ and go1.10.3+. But this approach works :) There is a possibility, that it can break some opensource toolset (maybe |
I haven't been following the vgo specification -- I've been waiting for the dust to settle. I trust @VojtechVitek 's intuition/direction on the matters so will take lead from you guys, but one of the goals of chi is to have no dependencies besides stdlib, so where do the require's for golang.org/x/net and /text come from? I do understand the need for versioning of chi and allowing other projects depend on a particular version of chi easily. |
personally I was happy with https://github.com/golang/dep but, the Go devs are much smarter than me, so I must be out of the loop on the latest thinking |
https://github.com/go-chi/chi/blob/master/middleware/middleware18_test.go#L12 We're using Actually, it's OK, because it doesn't force anyone to use your particular dependency version, it's just a minimal version. |
I don't think so. Afaik, the Unix users would have to switch to Since this situation is very uncomfortable for both v2.0+ pkg authors and consumers, I suggest not to release a For now... vgo pioneers (including myself) will have to stick to the require(
"github.com/go-chi/chi" v0.0.0-20180202194135-e223a795a06a
) (as suggested by @nicpottier in #302) |
@VojtechVitek sorry for answering so long, I was terribly busy these days :(
Actually, you're not quite right. Old go users on Unix won't have to do anything with their imports if they get this version. Please take a look at this test project https://github.com/mwf/chi-test-go1.8 So the only real stopper for the symlink way are Windows users. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old go users on Unix won't have to do anything with their imports if they get this version.
I'm not sure. Let me give you an example:
Imagine a project in Go 1.10 (or any other version that's not aware of "Go modules") that imports
import (
"github.com/go-chi/chi"
"github.com/go-chi/chi/middleware"
)
now.. if we merged this PR and user updated chi to a version with this new symlink hack, the github.com/go-chi/chi/middleware
pkg would suddenly start importing "github.com/go-chi/chi/v3"
instead of "github.com/go-chi/chi"
-- a different path => a different package.
Now, the user would technically end up with both
"github.com/go-chi/chi"
"github.com/go-chi/chi/v3"
in the codebase, which would cause type and context value mismatches.
I'd like to see Go authors to come up with an official solution that takes care of these v2+ upgrades.
cc @myitcv
@VojtechVitek I commented in golang/go#25967 (comment) |
From golang/go#25967 (comment)
|
Adding a ref to golang/go#26238 Go authors seem to understand the pain, so maybe they will start picking latest tagged version in automatic imports. Let's watch where it leads us. |
golang/go#26238 is closed, and you can try |
Import paths are changed according to Semantic Import Versions rationale.
Otherwise
vgo test ./middleware
fails bacause of import path interpretation - it assumesthat "github.com/go-chi/chi" points to v1, fails to find some public functions from v3 and dies.
As semantic import versioning seems to be the official way, we should respect it.
This is an experimental way of implementing #302 without major version bump.
Backwards compatibility is done via
v3
symlink - old go is OK with it.