dqayok7935 2016-04-12 00:34
浏览 89
已采纳

如何安装依赖项的二进制文件?

My Golang project depends on a few packages (i.e. https://github.com/mattes/migrate and https://github.com/joho/godotenv). I know I can go get or go install them separately, but is there a way to install all of the dependencies of a project in one shot? Ideally, I would expect go install ./... to put the migrate and godotenv binaries in my $GOPATH/bin, but it only installs the main package binary and not the binaries of the dependencies.

  • 写回答

1条回答 默认 最新

  • dpiz9879 2016-04-12 11:48
    关注

    Are you asking for a way to install the binaries you want to call, from your local machine, automatically from a go install ./... of your code?

    That isn't going to happen with straight up Go, unless they are listed in the same username or pattern you can type in a single go install command. But just the two listed above are different enough that that can't happen.

    Option 1) Either state to your users to call go install for each Dependency (this is very common).

    Option 2) Or, create a bash/batch file to run them with a simple install.sh command in your repo. Which, would call go install for all of your dependencies. Another more UNIX/C like approach would be to create a Makefile, and tell your users to run make

    Personally, I prefer option 2 as it gives you very complex control over your service or utility. You can start simple; but, later on add tests, go generate commands and whatever else you like in the future - all without having to change your installation instructions just run 'make install' and it will handle it. It also helps with C.I. servers that you can have a make test or anything to your hearts desire; but, different enough that normal users would usually run it. All, within a single Makefile that you can change later.

    I think my Updater script has like 25 go get -u -v commands.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c