I have a BUILD.bazel file containing a go_binary target. Inside this application, I need to access a YAML file (eg. config.yml) located in the same directory.
The go_binary looks like this:
go_binary(
name = "app1",
data = ["config.yml"],
embed = [":app1_lib"],
visibility = ["//visibility:public"],
)
I can see the file is added to the /private/var/tmp/_bazel/52b44015c7f2ec78df04b9a822df93c1/execroot/__main__/bazel-out/darwin-fastbuild/bin/services/app1/app1_/app1.runfiles/__main__/services/app1 folder.
What is the best way to access this file inside my Go app?
So far I found that I could do
url := fmt.Sprintf("%s/services/app1/config.yml", os.Getenv("PWD"))
...but I would like to avoid having to specify the folder structure explicitly.