2017-11-23 14:44

dep和bazel Go规则之间是否有联系?


Intro: dep is a tool to manage dependencies of Go projects. bazel is a build tool that produces stable, reproducable builds. There is a bazel rule set for Go projects, including an automatic build-file generator, gazelle, that generates Bazel build files following the conventions that go build would apply, using the dependencies declared in the bazel WORKSPACE.

The WORKSPACE, though, I have to create by hand or by help of a little hackish helper tool, wtool. dep, on the other hand, helps track dependencies, is able to download them into a vendor/ directory and locking specific versions.

To me it appears that the Gopkg.lock file that dep uses to specify versions of dependencies (usually by their VCS commit hash) would be easily translated into a bazel WORKSPACE file. I have successfully done so manually in a company-internal project as well.

Is there an existing link between bazel and its Go rules and dep that I could have used instead of doing this manually?

(Additionally: Is anybody else doing this? Should I be doing this at all?)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dqcd84732 dqcd84732 4年前

    There's no existing tool for this, but it should be pretty straightforward to convert entries in the lock file to WORKSPACE.

    We're thinking of a command to the Gazelle build file generator to help with this (not just for dep, but other tools as well). The main plan is for Gazelle to automatically add repositories that are missing, but that will take more time to implement.

    点赞 评论 复制链接分享
  • douqiang5163 douqiang5163 3年前

    There's a pretty new, and actively-being-developed project for this:

    点赞 评论 复制链接分享