Bazel/Golang:规则“go_embed_data”不包含声明的提供者“GoArchive”

我正在尝试为我的项目创建一个仅嵌入文件集合的 Bazel 规则。嵌入规则如下:


go_embed_data(

    name = "my_files_go",

    src = [

        "embedded/src1", "embedded/src2"

    ],

    package = "my_lib",

    var = "myFiles",

)

然后我将其添加到我的 go_library 规则中:


go_library(

    name = "library",

    srcs = [

        "library.go",

    ],

    importpath = "github.com/nickfelker/golang-app",

    deps = [

        ":my_files_go"

        "//otherLib",

    ],

)

但是,当我尝试构建它时,我最终得到了一个在其他地方找不到的模糊错误。


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

我应该如何解决这个错误?


犯罪嫌疑人X
浏览 115回答 1
1回答

繁花如伊

为其创建的规则go_embed_data不作为该go_library规则的依赖项。相反,它应该被视为其中之一srcs,如下所示:go_embed_data(&nbsp; &nbsp; name = "my_files_go",&nbsp; &nbsp; src = [&nbsp; &nbsp; &nbsp; &nbsp; "embedded/src1", "embedded/src2"&nbsp; &nbsp; ],&nbsp; &nbsp; package = "my_lib",&nbsp; &nbsp; var = "myFiles",)go_library(&nbsp; &nbsp; name = "library",&nbsp; &nbsp; srcs = [&nbsp; &nbsp; &nbsp; &nbsp; ":my_files_go",&nbsp; &nbsp; &nbsp; &nbsp; "library.go",&nbsp; &nbsp; ],&nbsp; &nbsp; importpath = "github.com/nickfelker/golang-app",&nbsp; &nbsp; deps = [&nbsp; &nbsp; &nbsp; &nbsp; "//otherLib",&nbsp; &nbsp; ],)
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go