Does go mod resolve transitive dependencies for an dep by default, and if so, what is the best way to deal with monorepos dependencies?

If I have a simple import such as:

import (
     "hello.io/example/client"
)

Then, will go mod tidy by definition, try to “import” (or more precisely transitively resolve) all of

hello.io/example/

?

Details

In my case, I only need to import a few files from the example/client directory shown above. Is there a straight forward way to do this? Some ideas I had:

  • make a separate git repo for hello.io/example/client and hello.io/example/server. This obviously has drawbacks.
  • make a separate go.mod for example/client and example/server.
  • use some kind of go mod magic to tell go mod "only worry about importing things from the directory referenced in the import clause.

I would prefer the 3rd option, but I don't see anything in go mod documentation about wether or not importing a subfolder from an external project is allowed.

Summary of the problem statement

So to summarize, the more detailed version of this question is does go mod tidy have the ability to only import certain parts of a dependency, or is it an all or nothing operation, and if the latter, what is the best way to carve up dependencies so as not to "import the world" when simply depending on a few files in a monorepo ?.

I've also tagged this question as "kubernetes" because, specifically, it pertains to the more detailed example here: https://github.com/kubernetes-sigs/kpng/issues/58 .



from Recent Questions - Stack Overflow https://ift.tt/3AHU2Kb
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Spring Elasticsearch Operations

Network Error and Timeout on Authorize.net JS

Object oriented programming concepts (OOPs)