• 请不要在回答技术问题时复制粘贴 AI 生成的内容
tmac33
V2EX  ›  程序员

Go mod 问题

  •  
  •   tmac33 · Aug 21, 2020 · 2296 views
    This topic created in 2091 days ago, the information mentioned may be changed or developed.

    go 项目很大,go mod 不得不引入一些私包,于是用 replace 关键字将远程包映射到当地提前 pull 下来的私包。 问题来了, 每当 run 的时候,只要其中一个私包更改过,就要重新 pull 一次。那每次手动全部操作一遍,很没有效率,大家有没有什么更好的办法?(比如,感知到私包的远程库有更改,那么主动更新本地私包,以确保项目 build 无误。)

    上过 go 大型业务代码的人,传授一下各位的经验。

    9 replies    2020-08-21 13:33:00 +08:00
    saberlong
        1
    saberlong  
       Aug 21, 2020 via Android   ❤️ 1
    我这边是不用 replace 。部署 athens 之类的本地仓库。GOPROXY 设置为 athens 。私有包走内部部署的 git 服务。设置 GOPRIVATE 让私有包不走 GOPROXY
    Leigg
        2
    Leigg  
       Aug 21, 2020 via Android
    使用相对路径语法也不行?
    replace ... => ../
    tmac33
        3
    tmac33  
    OP
       Aug 21, 2020
    @saberlong 感谢,您这个很有价值。我研究一下
    dbskcnc
        4
    dbskcnc  
       Aug 21, 2020 via Android
    go mod 不会主动更新版本的, 你的要求
    dbskcnc
        5
    dbskcnc  
       Aug 21, 2020 via Android
    需要自己写脚本处理
    sxfscool
        6
    sxfscool  
       Aug 21, 2020
    私有包不也有 git 地址么,直接 replace 到 git 仓库地址就行,不用 pull 到本地
    sxfscool
        7
    sxfscool  
       Aug 21, 2020
    goproxy 设置为 https://goproxy.cn,direct , GOPRIVATE 设不设都行
    pandanrain123
        8
    pandanrain123  
       Aug 21, 2020
    git submodule 配合 replace 应该可以吧
    index90
        9
    index90  
       Aug 21, 2020
    export GOPROXY=https://goproxy.cn,direct
    export GONOSUMDB=你的 git 仓库域名
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3309 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 11:46 · PVG 19:46 · LAX 04:46 · JFK 07:46
    ♥ Do have faith in what you're doing.