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.

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

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?