-2

Saying I'm developing a plugin p of a system A, so p naturally depends on A when developing and testing.

But this kind of dependency is not necessary once p integrated with A. In maven the dependency can be claimed with a provided scope to avoid unnecessary version conflict.

How could this to be achieved in go modules?

Yalou Wang
  • 265
  • 2
  • 6

1 Answers1

1

No, it does not. But this is not much of a problem. Say you have foo_test.go, which includes a dependency of to foo/bar/baz. Now, this dependency will only be linked into the test binary go testcompiles on the fly. It will not be included into the "main" binary.

This is one advantage of Go - the compiler identifies what needs to be linked and using Go modules, he has a bill of material which not only defines the required dependency by name, but down to the very commit.

As written, think of the content of go.mod more like a bill of materials which are needed at one point or the other when working with the project and not like a set of instructions to build a fat JAR.

Side note: even maven dependencies typically do not go into the resulting JAR. Spring Boot does this, but that is NOT the default maven behavior; building skinny JARs is.

Markus W Mahlberg
  • 19,711
  • 6
  • 65
  • 89