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 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据