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 test
compiles 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.