-
Notifications
You must be signed in to change notification settings - Fork 306
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
Troubles with Go modules and version mismatches #321
Comments
Thanks for the report. I fear you are hitting intrinsic UX issues with the whole Go module machinery, and I don't think there is much I can do as a maintainer of this library. For the standalone example, see #320 (comment) which explains the Go module switch. For the etcd case, I think you can ask the etcd maintainers to bump the dependency on their side, or stick to use the same go-systemd version they pinned. |
I Add this in my go.mod
then go mod tidy, and I made it. It will become
|
Yes, I was aware of the switch, to Go Modules in v22.0.0, which is great. I don't know enough about modules yet, though, to properly understand the source of or reaseon this error, though.
Or capnslog I guess. How do I pin the version? Or is it better to follow @jarsaccount's suggestion? I added
To my |
This comment has been minimized.
This comment has been minimized.
@theory to the best of my understanding, the "versionless replace" hack should work as long as the versioned and non-versioned releases of this library have no API-breaking changes. |
For casual readers landing here, Go modules require semver-imports as explained in the official docs: https://github.com/golang/go/wiki/Modules#semantic-import-versioning. This means that the proper way to consume this library is via versioned imports as shown in the original bug-report here and in examples:
That also means that, in the future, updating to new API-breaking releases will require updating all import paths (e.g. from As an unfortunate side-effect of Go module design, mixing imports from modular and non-modular versions results in some pain (as shown above) and requires some hacks via |
Yes, but note that I demonstrated the issue with no dependencies, using nothing more than package main
import _ "github.com/coreos/go-systemd/journal"
func main() {} I think the solution is to either:
Not sure why that is. |
@theory to the best of my understanding, the
Thus, the correct import line would be |
Oooh, okay, thanks for the clarification. I guess that makes sense, as it’s more consistently explicit. |
Anyway, just to cover the technical side once more:
|
This comment has been minimized.
This comment has been minimized.
So. How to use the latest untag version
Just for memo. If someone want use latest untag version. You can change to
😂 |
For those who don't want to use the import directive: This is how it can be done: go.mod file: module foo
go 1.16
require (
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
) some go file import (
"context"
"github.com/coreos/go-systemd/v22/dbus"
)
... |
For whatever reason I tripped over this. Adding the version in the import path is the correct solution. import _ "github.com/coreos/go-systemd/v22/journal" |
I was just converting a project to a Go module, and was pleased to see #307 merged and v22.0.0 tagged. So I was trying to rely on the go-systemd module, but ran into an error:
I can trigger this error with this simple program:
I can fix it by changing the import to
github.com/coreos/go-systemd/v22/journal
; however, that doesn't help when I try to import, say, etcd, which gives me this error:I guess this can be fixed by capnslog adding
v22
to its import, but I don't think that package has been modularized, yet. Is there some other way I can getgo mod
and friends to find v22 as the latest?The text was updated successfully, but these errors were encountered: