reproxy icon indicating copy to clipboard operation
reproxy copied to clipboard

Make github.com/umputun/reproxy/lib a submodule

Open ShoshinNikita opened this issue 3 years ago • 2 comments

Import of github.com/umputun/reproxy/lib adds github.com/umputun/reproxy to go.mod. It results in a significant number of dependencies.

At the same time, github.com/umputun/reproxy/lib requires only 3 dependencies:

  • github.com/go-pkgz/lgr
  • github.com/go-pkgz/repeater
  • github.com/stretchr/testify

Making github.com/umputun/reproxy/lib a submodule can resolve this issue.

However, this change will also require some additional work:

  • manage 2 versions: vX.Y.Z for github.com/umputun/reproxy and lib/vX.Y.Z for github.com/umputun/reproxy/lib
  • github.com/umputun/reproxy/lib will have to be vendored (see https://github.com/golang/go/issues/33789 and https://github.com/hashicorp/nomad/pull/10898)
  • users of github.com/umputun/reproxy/lib will have to update dependency path and version

I don't think these points are very critical: API of github.com/umputun/reproxy/lib is pretty stable, and the current version (v0.10.0) allows to make breaking changes

ShoshinNikita avatar Nov 15 '21 20:11 ShoshinNikita

this is a valid concern. Making submodule in go is smth awkward a little bit with an additional tag we will have to maintain for lib. However, breaking dependency to the github.com/umputun/reproxy is worth it in my opinion.

I'm not sure I understand the meaning of "will have to be vendored" item. Does it mean vendored by reproxy itself because it will be treated as a module and won't be resolvable "directly" anymore? Are you saying this won't work anymore unless vendored?

zcqje-202111-15155123-4k00w

umputun avatar Nov 15 '21 21:11 umputun

Does it mean vendored by reproxy itself because it will be treated as a module and won't be resolvable "directly" anymore? Are you saying this won't work anymore unless vendored?

Yes, you are right.

From https://github.com/golang/go/issues/33789:

At the moment, this is working as designed: go mod vendor doesn't know (or particularly care) about the overall repo structure — it just knows where the main module is and vendors in the dependencies of the main module wherever they are found.

Some workarounds:

  • use a symlink for a local module like github.com/gravitational/teleport - https://github.com/gravitational/teleport/blob/master/Makefile#L923
  • add a helper script to vendor a local module like github.com/hashicorp/nomad (they don't vendor deps anymore) - https://github.com/hashicorp/nomad/pull/10898

But as I said, github.com/umputun/reproxy/lib should be pretty stable. So, I don't think it will be a big problem

ShoshinNikita avatar Nov 16 '21 19:11 ShoshinNikita