I'm trying to create a Bazel rule for my project that just embeds a collection of files. The embed rule is as follows:
go_embed_data(
name = "my_files_go",
src = [
"embedded/src1", "embedded/src2"
],
package = "my_lib",
var = "myFiles",
)
Which I then add in my go_library rule:
go_library(
name = "library",
srcs = [
"library.go",
],
importpath = "github.com/nickfelker/golang-app",
deps = [
":my_files_go"
"//otherLib",
],
)
However when I try to build this, I end up getting an obscure error that I cannot find elsewhere.
Error: <target //library:my_files_go> (rule 'go_embed_data') doesn't contain declared provider 'GoArchive'
ERROR: Analysis of target '//:binary' failed; build aborted: Analysis of target '//library:library' failed
How am I supposed to get around this error?
The rule created for go_embed_data
does not go as a dependency to the go_library
rule. Instead, it should be considered one of the srcs
, as so:
go_embed_data(
name = "my_files_go",
src = [
"embedded/src1", "embedded/src2"
],
package = "my_lib",
var = "myFiles",
)
go_library(
name = "library",
srcs = [
":my_files_go",
"library.go",
],
importpath = "github.com/nickfelker/golang-app",
deps = [
"//otherLib",
],
)