bottlerocket-os / twoliter

A build tool for customizing Bottlerocket
Other
24 stars 25 forks source link

fetch-vendored fails on nested golang modules #311

Open cbgbt opened 5 months ago

cbgbt commented 5 months ago

When twoliter searches for golang modules, it recursively finds all go.mod files and assumes that a module exists with the parent directory name.

Consider golang sources arranged as such under the sources directory:

hello-go
├── cmd
│   └── hello-go
│       └── main.go
├── embedded-mod
│   ├── cmd
│   │   └── embedded
│   │       └── main.go
│   └── go.mod
└── go.mod

In this case, find_go_modules() will return ["hello-go", "embedded-mod"]. When fetching vendored dependencies, twoliter later assumes that all configured GO_MODULES will live directly under sources.

The solution to this may be as simple as having find_go_modules() return the module path relative to sources, but I haven't looked more deeply into what impact this has on how golang tooling is later invoked.