dousi6405 2018-09-20 07:08
浏览 77
已采纳

go模块如何与可安装命令一起使用?

I've recently started with Go 1.11 and love the modules. Apart from runtime dependencies I need to work with go modules during the build, e.g. during go generate.

How can I install a specific build dependency (e.g. github.com/aprice/embed/cmd/embed) and run that specific tool from which folder? Is go get the right tool for doing so?

  • 写回答

5条回答 默认 最新

  • dongxi2014 2019-01-05 04:55
    关注

    https://github.com/golang/go/issues/25922 proved helpful for me, especially

    when using build-only dependencies with modules the main point is version selection (not installing these!)

    To avoid installing you can modify your //go:generate directive to something like:

    //go:generate go run golang.org/x/tools/cmd/stringer ARGS
    

    There is also the best practices repo: https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 fluent设置了自动保存后,会有几个时间点不保存
  • ¥20 激光照射到四象线探测器,通过液晶屏显示X、Y值
  • ¥15 这怎么做,怎么在我的思路下改下我这写的不对
  • ¥50 数据库开发问题求解答
  • ¥15 安装anaconda时报错
  • ¥20 如何用Python处理单元格内连续出现的重复词语?
  • ¥15 小程序有个导出到插件方式,我是在分包下引入的插件,这个export的路径对吗,我看官方文档上写的是相对路径
  • ¥20 希望有人能帮我完成这个设计( *ˊᵕˋ)
  • ¥100 将Intptr传入SetHdevmode()将Intptr传入后转换为DEVMODE的值与外部代码不一致
  • ¥50 基于ERA5数据计算VPD