doujichan1399 2018-12-04 06:08
浏览 182


When adding new dependencies using dep ensure -add <package> I see dep adding the complete repository of the package, instead of just the parts I require.

For example I added aws-sdk-go and dep ensure put 87MB of files into my vendors folder, even though I only use the AWS Secrets Manager service.

  • 写回答

1条回答 默认 最新

  • dsgixl5195 2018-12-04 06:08

    To resolve this you need to define [prune] settings which determine what files and directories can be deemed unnecessary, and thus automatically removed from vendor/.

    The following options are currently available:

    • unused-packages indicates that files from directories that do not appear in the package import graph should be pruned
    • non-go prunes files that are not used by Go
    • go-tests prunes Go test files

    Out of an abundance of caution, dep non-optionally preserves files that may have legal significance.

    Pruning options are disabled by default. However, generating a Gopkg.toml via dep init will add lines to enable go-tests and unused-packages prune options at the root level.

      go-tests = true
      unused-packages = true

    The same prune options can be defined per-project. An additional name field is required and, as with [[constraint]] and [[override]], should be a source root, not just any import path.

      non-go = true
        name = ""
        go-tests = true
        non-go = false

    Almost all projects will be fine without setting any project-specific rules, and enabling the following pruning rules globally:

      unused-packages = true
      go-tests = true

    It is usually safe to set non-go = true, as well. However, as dep only has a clear model for the role played by Go files, and non-Go files necessarily fall outside that model, there can be no comparable general definition of safety.

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



  • ¥15 Arduino,利用modbus的RS485协议,进行对外置的温湿度传感器进行数据读取
  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么