[chore] Migrate to go.mod tool directives#45739
Conversation
a07e1d1 to
216542f
Compare
|
There's some annoying edge cases related to local commands (schemagen, codecovgen) which shouldn't really need a tool entry at all. I'll come back to it next week. |
Simplify by removing these local tools from tools.go, instead running them directly with "go run". This is an offshoot of open-telemetry#45739
Simplify by removing these local tools from tools.go, instead running them directly with "go run". This is an offshoot of open-telemetry#45739
#### Description Introduce a `make mdatagen` target, which defaults to invoking the tool with metadata.yaml in the module directory. The metadata.yaml file path may be overridden by setting the env var MDATAGEN_METADATA_YAML. This will simplify moving away from installing tools, and using "go tool". Offshoot of #45739 #### Link to tracking issue N/A #### Testing N/A #### Documentation Updated docs/new-components.md
#### Description Simplify by removing these local tools from tools.go, instead running them directly with "go run". This is an offshoot of #45739, which will remove internal/tools/tools.go and use go.mod tool directives. For these local tools, it's simpler just to run them directly. #### Link to tracking issue N/A #### Testing N/A #### Documentation Updated cmd/schemagen/README.md to remove mention of install-tools approach
1bd1213 to
7124233
Compare
|
I've now bumped into golang/go#72824, which is fixed in Go 1.25. Rather than complicating the Makefile, I'll put this on hold until we've updated to Go 1.25, which should be soon (Go 1.26 is due to be released in February 2026.) |
0e0065e to
8c8aa0b
Compare
mx-psi
left a comment
There was a problem hiding this comment.
LGTM, though I am scared that we will accidentally break something when doing this and it will be hard to notice. Is there any way to mitigate that?
@mx-psi is there a specific concern you have? Otherwise I don't know how to answer, other than to do nothing. We can and should quickly revert it if it breaks something. Given that the change is to move from running a command in |
We have had issues in the past where a subset of tests were not running and it was hard to identify (see #30901 and #32518), I want to avoid that. I don't have a good solution for avoiding these kinds of issues and the code looks reasonable to me, so I am just going to merge this and we can keep an extra eye on this. |
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Follow up from #45739 to use Make to invoke githubgen. I tried to clean things up a bit, but wasn't sure what should be used when and what makes sense to change. I've opened an issue to track this in case anyone would like to go deeper: #46150.
#### Description Modernise Go build tool dependency management, switching from the old "tools.go" approach to go.mod tool directives, and removing the need for explicitly installing tools. Tools are now invoked with `go tool <package/path>`. The tool directive for `genqlient` has been added directly to githubreceiver, which was the only component using it. See this core collector PR for reference: open-telemetry/opentelemetry-collector#13906 #### Link to tracking issue None #### Testing N/A #### Documentation Updated
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Follow up from open-telemetry#45739 to use Make to invoke githubgen. I tried to clean things up a bit, but wasn't sure what should be used when and what makes sense to change. I've opened an issue to track this in case anyone would like to go deeper: open-telemetry#46150.
Description
Modernise Go build tool dependency management, switching from the old "tools.go" approach to go.mod tool directives, and removing the need for explicitly installing tools. Tools are now invoked with
go tool <package/path>. The tool directive forgenqlienthas been added directly to githubreceiver, which was the only component using it.See this core collector PR for reference: open-telemetry/opentelemetry-collector#13906
Link to tracking issue
None
Testing
N/A
Documentation
Updated