Hi Gophers,
I'm adding to an existing proposal regarding the need to better understand the purpose of dependencies within a Go module, specifically distinguishing between those used for the main build and those used solely for testing.
Building on the idea that this information is valuable for improved dependency management and project comprehension (especially in open-source projects where a quick understanding is key), I wanted to specifically suggest an implementation focused on static annotations within the go.mod file itself.
The core of this idea is for the go mod tool to automatically add a `// test` comment to direct dependencies and `// indirect, test` to indirect dependencies that are exclusively imported by test files.
I believe this approach prioritises "glanceability," allowing developers to immediately see which dependencies are test-related without relying on separate tooling or commands. The go mod tool would be responsible for generating and maintaining these comments directly within the go.mod file.
While the original proposal explored other avenues (including more tooling-centric outputs), I feel that embedding this information directly in go.mod offers significant value in terms of immediate visibility and ease of understanding.
I'm keen to hear the community's thoughts on this specific implementation approach. Do you see the benefit of having these static annotations directly in the go.mod file? Would this level of transparency be helpful in the way you work or choose an open-source project?
The original issue/proposal can be found here.
Looking forward to the discussion!
Kind Regards,
Andrew Wormald