dpsr1670 2013-06-09 23:37
浏览 56
已采纳

Go是更喜欢从远程存储库中获取还是更喜欢使用本地文件?

Let's assume that my entire repository is at both github.com/my_repo and local file system. A source file imports "github.com/my_repo/pkg". When I run go run, does go fetch the remote file and import it, or does it prefer local files?

What if there is a generic remote repository (not github/launchpad/etc), will go prefer to fetch remote repository or prefer to use local files?

  • 写回答

3条回答 默认 最新

  • drtohng5613 2013-06-10 00:22
    关注

    As per http://golang.org/doc/code.html#remote

    If the specified package is not present in a workspace, go get will place it inside the first workspace specified by GOPATH. (If the package does already exist, go get skips the remote fetch and behaves the same as go install.)

    Or, in other words:

    1. Go will check for the package locally in your $GOPATH
    2. If it doesn't exist, Go will call go get and fetch it.

    This is worth noting if you are expecting a specific version of a repo: go will grab the latest for the version of Go installed. If the repo doesn't have specific tags, it will grab the head from the master branch. It's generally a good idea to note the version of the repo you need somewhere in your version control/documentation to ensure you don't get a later (and potentially breaking) repo.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 目标计数模型训练过程中的问题
  • ¥100 Acess连接SQL 数据库后 不能用中文筛选
  • ¥15 用友U9Cloud的webapi
  • ¥20 电脑拓展屏桌面被莫名遮挡
  • ¥20 ensp,用局域网解决
  • ¥15 Python语言实验
  • ¥15 我每周要在投影仪优酷上自动连续播放112场电影,我每一周遥控操作一次投影仪,并使得电影永远不重复播放,请问怎样操作好呢?有那么多电影看吗?
  • ¥20 电脑重启停留在grub界面,引导出错需修复
  • ¥15 matlab透明图叠加
  • ¥50 基于stm32l4系列 使用blunrg-ms的ble gatt 创建 hid 服务失败