I'm using the go_test
rule from rule_go in Bazel, and I'd like to access the workspace directory at runtime. I can't find it in the environment variables, and $PWD
is the temp sandbox directory. How can I access this variable? Ideally, it's something I can pass into my rule and not a command-line argument to bazel test
so that I don't have to write it out every time.
Typically you would use the data
attribute to declare files that you want to access at runtime. The docs for go_test.data
https://github.com/bazelbuild/rules_go/blob/master/docs/go/core/rules.md#go_test-data
point to this library
https://pkg.go.dev/github.com/bazelbuild/rules_go/go/tools/bazel
for conveniently accessing data dependencies.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.