My project has the following structure:
├── api
│?? ├── api.go
│?? ├── api_test.go
│?? ├── other_files...
├── cmd
│?? └── main.go
Under cmd/main.go I have the entrypoint of my Go project.
Since I am also creating some test files, I have other classes used for test purposes.
My go.mod is like:
require (
github.com/gorilla/mux v1.8.0
github.com/stretchr/testify v1.6.1 <-used for test
gotest.tools v2.2.0+incompatible <-used for test
k8s.io/api v0.19.0
k8s.io/apimachinery v0.19.0
k8s.io/client-go v0.19.0
)
My doubt is related to the build phase:
When doing go build ./cmd/main.go
, am I selecting only the correct modules used from main.go
and all his references across the code, excluding the unused modules listed in go.mod
used for test classes?
Is there any ldd
command to be sure I am linking only the required modules?
I assume that Go is optimized to do that, but I would like to be sure about that.
question from:
https://stackoverflow.com/questions/65844499/build-excluding-test-modules 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…