我正在按照“使用Bazel構建Go服務”youtube中的步驟操作,并創建了一個具有依賴項的簡單項目,該項目無法構建并出現錯誤:ERROR: /builds/mvfwd/issue-bazel-go/cmd/BUILD.bazel:3:11: no such package '@com_github_pallinder_go_randomdata//': The repository '@com_github_pallinder_go_randomdata' could not be resolved and referenced by '//cmd:cmd_lib'ERROR: Analysis of target '//cmd:cmd' failed; build aborted: Analysis failedINFO: Elapsed time: 1.263sINFO: 0 processes.FAILED: Build did NOT complete successfully (1 packages loaded, 165 targets configured)FAILED: Build did NOT complete successfully (1 packages loaded, 165 targets configured)整條日志版本$ bazel --versionbazel 4.1.0$ go versiongo version go1.17 linux/amd64文件結構項目: https://gitlab.com/mvfwd/issue-bazel-go厘米/BUILD.bazel你好,去hello_test建工作去模組去總和步驟見.gitlab-ci.ymlgo mod init gitlab.com/mvfwd/issue-bazel-go創建go.modgo mod tidy創建go.sumbazel run //:gazelle創建cmd/BUILD.bazelbazel build ...失敗并顯示錯誤認為這可能是因為“go-randomdata”中的破折號,所以添加了另一個非破折號依賴關系(github.com/stretchr/testify/assert),得到了同樣的問題。我做錯了什么?我錯過了什么嗎?UPD:解決方案是使用以下組合$ bazel run //:gazelle
$ bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=deps.bzl%go_dependencies
$ bazel run //:gazelle如此處所述。 部分將使用所有必要的依賴項更新工作區。update-repos...
1 回答

回首憶惘然
TA貢獻1847條經驗 獲得超11個贊
解決方案是使用以下組合
$ bazel run //:gazelle
$ bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=deps.bzl%go_dependencies
$ bazel run //:gazelle
如此處所述。
update-repos...部分將使用所有必要的依賴項更新文件。WORKSPACE
- 1 回答
- 0 關注
- 149 瀏覽
添加回答
舉報
0/150
提交
取消