1

I am new to Go and trying to create my first program. Following the various getting started & tutorials I create a new module, which for my purpose needs to have a dependency on this module:

github.com/timescale/promscale@0.6.2

My problem is that the module has dependencies that have not "properly adopted" the semantic versioning approach.

go list -e -m all
...
k8s.io/client-go v12.0.0+incompatible
...

reports 37 such modules... so contacting the module author to have them adopt SIV, as I have seen suggested, will not be an option.

Am I missing something, or should I simply completely give up on using modules for this new project?

franck102
  • 221
  • 4
  • 14
  • 7
    You should not give up, modules are the preferred and suggested way. Having an "incompatible" dependency doesn't mean it does not work. See [What does 'incompatible' in go.mod mean, will it cause harm?](https://stackoverflow.com/questions/57355929/what-does-incompatible-in-go-mod-mean-will-it-cause-harm) – icza Nov 25 '21 at 16:56
  • I had seen that post, and I assumed the opposite conclusion. It mentions that go get will not work, and that I should contact the module author. If the solution is to use one of the 5 workarounds mentioned in the second post, I’ll definitely give up on modules, the level of complexity just doesn’t make any sense for a 5 line hello world project. – franck102 Nov 25 '21 at 19:19
  • You can’t really give up on modules, since they are required for working with any dependencies, nearly all of which use modules. – JimB Nov 25 '21 at 22:13

2 Answers2

2

Are Go modules really usable today given third party "incompatible" modules?

Yes.

Am I missing something

Maybe: This "+incompabtible" is not a sign of failure.

or should I simply completely give up on using modules for this new project?

No, of course not.

Volker
  • 40,468
  • 7
  • 81
  • 87
  • It is failing. Go get -m all reports an error instead of the list of dependencies. If your suggestion is to try to set up proxies or the similar workarounds mentioned in https://stackoverflow.com/questions/57355929/what-does-incompatible-in-go-mod-mean-will-it-cause-harm I will definitely pass on that feature. – franck102 Nov 25 '21 at 19:23
  • 1
    @franck102 I doubt the problem is on the side of the dependecies. E.g. k8s.io/client-go has properly adopted Go modules and explains in detail what to do to get it running https://github.com/kubernetes/client-go/blob/v0.22.4/INSTALL.md#troubleshooting . Maybe you should update some dependencies on _your_ side? Also: Your question stated that `go get list -e -m all` reports problem. Now `go get list` is nonsense and probably should be `go list`. Start with these things, not fancy proxie stuff. – Volker Nov 26 '21 at 05:27
  • Indeed I meant "go list -m all", I have edited the post. That breaks Goland dependency handling which apparently uses go lsit under the hood , I managed to fix that using GOFLAGS=-e. I was able to get go build to work after a couple manual "go get" suggested by the command. – franck102 Nov 26 '21 at 06:56
  • 1
    `go get` adds dependencies. Without explicitly (what you call "manual") adding them they are just missing. This is not a problem of modules. – Volker Nov 26 '21 at 07:21
  • I meant "go list -m all" as well in my initial comment, sorry. W.r.t. k8s.io/client-go the issue I assume comes from how timescale/promscale or some other transitive dependency requires it, which is something I don't control. – franck102 Nov 26 '21 at 07:26
0

Thanks for the answers and comments, it seems that:

  1. New project should use modules, +incompatible dependencies will come up but that is fine

  2. This FAQ entry has it right, just read the first 2 lines and keep "Additional Details" for a rainy day

  3. go list -m all won't behave as described in all the tutorials if +incompatible dependencies exist, it will choke on the first incompatible module instead.

go list -m -e all seems to work as expected.

If you are using Goland, using GOFLAGS=-e seems to make dependency resolution work despite +incompatible modules. This may well have side effects that I am not aware of.

franck102
  • 221
  • 4
  • 14