bazel-contrib / bazel-contrib/rules_go
Correct approach for running a binary as part of a rule which needs to invoke go down the line
- Dominant language
- Go
- Stars
- 1.5k
- Forks
- 760
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 12
Description
I have encountered a situation, whereupon a codegen app, running from a bazel rule, wants to invoke "golang.org/x/tools/imports".Process. This seems to be pretty reasonable; unfortunately `Process` wants to invoke a `go` command somewhere inside it.
Go would not resolve executables via relative paths, so simply conjuring a dirty "PATH" out of "GOROOT" is not an option. I can hackishly obtain an absolute path out of relative GOROOT value, export that in my own simple wrapper and go from there.
However, should not there be some sort of standard way to do such things?
Code generation is increasingly important topic, and thus there's more need to write custom code generator tooling which may need to invoke bits and pieces of the toolchain.
Contributor guide
Research direction
The issue does not name files or tests. Start by tracing the Bazel rule and code-generation entry point that invokes golang.org/x/tools/imports.Process, then examine how GOROOT, PATH, and the go executable are exposed; done means documenting or establishing a standard supported approach for this toolchain invocation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100