dosrmo0442 2017-11-17 12:37
浏览 102

Gazelle可以为外部Go项目运行吗?

I have a Bazel WORKSPACE from which I'd like to import an external Go git repository. I'm wondering if best-practise is to always have the Gazelle BUILD.bazel files or if my source WORKSPACE somehow can trigger Gazelle to generate the files so I don't need to check them in? The latter is this case makes sense if I'm not the owner of the upstream repo.

  • 写回答

1条回答 默认 最新

  • drxv39706 2017-11-21 15:55
    关注

    Is the external git repository a regular Go repo? Can "go get" build it? If so, the current best practice is to use go_repository in your WORKSPACE file. Something like this:

    load("@io_bazel_rules_go//go:def.bzl", "go_repository")
    
    go_repository(
        name = "org_golang_x_tools",
        importpath = "golang.org/x/tools",
        commit = "663269851cdddc898f963782f74ea574bcd5c814",
    )
    

    This will check out the repository and generate build files inside using Gazelle. It also handles Go import path redirection.

    If the repository doesn't build cleanly this way, you can check it out, generate a single build file using Gazelle's -experimental_flat flag, modify it as needed, and use that with new_git_repository or new_http_archive. This workflow is pretty awkward right now, and we plan to simplify it a lot in the future.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?