0

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?

Abdollah
  • 4,579
  • 3
  • 29
  • 49
melina
  • 195
  • 1
  • 8
  • 1
    If you're using Go modules (added in v1.11), you can just use `go get github.com/googollee/go-socket.io@v1.4.0` (or whatever 1.4.x version you want). – Adrian Sep 10 '19 at 18:48
  • @Adrian , My dear go get github.com/googollee/go-socket.io@v1.4.0 dont work – melina Sep 10 '19 at 19:07
  • @Adrian go: cannot use path@version syntax in GOPATH mode – melina Sep 10 '19 at 19:08
  • 1
    Correct - that's why I started off saying "If you're using Go modules". If you are using a recent version of Go, you might consider updating your project to use modules, it makes it much easier to manage dependencies like this where you want a specific version. – Adrian Sep 10 '19 at 19:41
  • @Adrian how can i use Go modules ? – melina Sep 10 '19 at 19:54
  • @Adrian , i want to install v1.0 , v1.4 and.... my go veriosn : go version go1.12.9 windows/amd64 – melina Sep 10 '19 at 19:55
  • https://github.com/golang/go/wiki/Modules – Adrian Sep 10 '19 at 20:25
  • @Adrian can you connect my pc with teamviewer and solve my problem? – melina Sep 10 '19 at 21:13
  • i use this https://github.com/zhouhui8915/socket.io-go and run go get github.com/googollee/go-socket.io – melina Sep 11 '19 at 00:15

1 Answers1

-1

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.

Community
  • 1
  • 1
Abdollah
  • 4,579
  • 3
  • 29
  • 49