doufen5175 2019-09-10 18:39
浏览 640

我如何使用go get命令从github中提取软件包的较旧分支

From this link:

https://github.com/googollee/go-socket.io/tree/v1.4

I want to get this module. How can I do it? I don't want to get master module, but I want to get v1.4 branch. When I use the following command, it downloads master module:

go get github.com/googollee/go-socket.io

How can I use go get for an older version or other branches?

  • 写回答

1条回答 默认 最新

  • duanli6834 2019-09-10 19:25
    关注

    UPDATE

    You need to use modules. Module-based behavior is an opt-in feature that is available from Go 1.11 but it is disabled by default in %GOPATH% directory. (If you don't know your %GOPATH%, run go env.) For example, if your %GOPATH% is set to C:\Users\Melina\go (I suppose so in the remainder of the answer), you cannot use module-based behavior of go get in that directory or its subdirectories likeC:\Users\Melina\go\src regarding default settings. To change it, do the following steps:

    1. Set GO111MODULE environment variable to on

      Add an environment variable called GO111MODULE and set it to on. (You can do this simply by running command setx GO111MODULE "on" in Windows shell either Command Prompt or Windows Powershell. You MUST repoen the shell so it takes effect. Or if you are using Visual Studio Code, restart your IDE.)

    2. In C:\Users\Melina\go\src, create a directory called e.g. socket.io.1.4. It will contain source code of socket.io module. Run the following commands:

    3. cd C:\Users\Melina\go\socket.io.1.4

    4. go mod init github.com/googollee/go-socket.io@v1.4 to create a module that pulls v1.4 of go-socket.io.

    5. go get github.com/googollee/go-socket.io@v1.4 to get the specified version of the module. Getting the module will start like this: enter image description here

    There is an alternative way without touching GO111MODULE. Since out of %GOPATH%, the module-based behavior is enabled by default, you can do step 2 out of %GOPATH%, i.e. create directory socket.io.1.4 out of C:\Users\Melina\go and its subdirectories. Other steps are the same.

    评论

报告相同问题?

悬赏问题

  • ¥15 请分析一下这个电路设计的优点🙏
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 怎么改成输入一个要删除的数后现实剩余的数再输入一个删除的数再现实剩余的数用yes表示继续no结束程序
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取