我如何使用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?

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.