dsfovbm931034814 2016-05-11 09:18
浏览 43
已采纳

如何将软件包添加到Godeps

I Already have a existing project in github and have deps json file stored in Godeps folder and dependency packages in vendor folder.

Now I need a way to add a new package to the list without effecting anything to the existing json file and vendor package folder

  • 写回答

1条回答 默认 最新

  • duanguan3863 2016-05-11 15:30
    关注

    Don't fight the tooling. Let godep update your json file and vendor folder, no matter how much it disturbs your pristine Godeps/godeps.json file.

    godep restore     // put everything in a known state
    go get -u foo/bar // get new package
    go test ./...     // make sure everything is up to snuff
    go run main.go    // run your code
    godep save ./...  // update `godeps.json` to current state of packages
    

    If you use go get -u foo/bar for your new package, this only affects your new package of foo/bar - it does not update your existing packages.

    The -u flag instructs get to use the network to update the named packages and their dependencies. By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages. https://golang.org/cmd/go/

    As a side note, I recommend getting in the habit of using godep prefixes so not to disburb your $GOPATH:

    go get -u foo/bar     // get new package
    godep go test ./...   // test your package, using your /vendor deps
    godep go run main.go  // run your code, using your /vendor deps
    godep save ./...      // update godeps if everything checks out
    

    It makes switching multiple repos much easier.

    Tip: make your configuration defaults sensible for your "local development environment" for your team. E.g. DB username/password like "dev/dev" and so on. That way, you don't have to pass parameters with godep go run main.go. Nice and simple.

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

报告相同问题?

悬赏问题

  • ¥15 请问异常处理之后怎样继续后面的程序呀?
  • ¥15 懂Matlab的人,可以帮我看看第四题和第五题应该怎么才能运行出来,或者可以提供一点相关的思路
  • ¥15 cv2.fisheye.stereoCalibrate报错
  • ¥20 求自动化运维语料数据集
  • ¥30 广告检测流量作弊案例 IDEA运行代码报错 连接不上metastore 检测了环境配置没有问题 请求远程解决加VX问细节问题 不加的不回复
  • ¥15 matlab图像融合代码被嫌弃太简单,求改进。第一步改成直接读取三张图片,不读取文件夹
  • ¥20 微处理器原理与应用(私有偿)
  • ¥50 8051单片机关于ADC0809的应用
  • ¥15 有没有能拿来练练手写完发给我
  • ¥15 禁止修改windows系统时间