1

What version of Go are you using (go version)?

$ go version
v1.12

The module yiigo has tag v3.0.0, but when I run go get github.com/iiinsomnia/yiigo, it gets the v2.1.0 and when I run go get github.com/iiinsomnia/yiigo@v3.0.0, it shows: go get github.com/iiinsomnia/yiigo@v3.0.0: unexpected end of JSON input

IIInsomnia
  • 11
  • 1

2 Answers2

0

The primary issue seems to be that the v3.0.0 version of iiinsomnia/yiigo is missing the required /v3 at the end of the module line in its go.mod file:

https://github.com/iiinsomnia/yiigo/blob/v3.0.0/go.mod#L1

module github.com/iiinsomnia/yiigo    <<<< wrong, missing required /v3 at end

go 1.12

require (
    github.com/go-sql-driver/mysql v1.4.1-0.20190217072658-972a708cf979
    ...

That has since been corrected.

Because it is now a proper v3 module, the go get command should include a /v3 before the @:

module github.com/iiinsomnia/yiigo/v3@v3.2.2

From the Go modules wiki:

If the module is version v2 or higher, the major version of the module must be included as a /vN at the end of the module paths used in go.mod files (e.g., module github.com/my/mod/v2, require github.com/my/mod/v2 v2.0.0) and in the package import path (e.g., import "github.com/my/mod/v2/mypkg").

Also, it looks like a related issue was opened, with the theory being that the odd "unexpected end of JSON input" error might have come from some proxy:

https://github.com/golang/go/issues/30494

thepudds
  • 4,787
  • 3
  • 20
  • 37
-1

A way I've accomplished this in the past is by using git tags- for your case this should work fine.

Steps:

  1. go get -u github.com/iiinsomnia/yiigo
  2. cd ~/go/src/github.com/iiinsomnia/yiigo
  3. git tag
  4. locate tag release version you'd like to install within list
  5. git checkout v3.0.0
  6. go install

This will overwrite the package previously installed in your GOPATH with a new one for the specific tag version you have checked out.

Note: there is likely a better way to do this since the release of go modules.

This related post also provides alternative solutions on how to retrieve a specific version of a project's source code that may lend some help.

jonroethke
  • 1,152
  • 2
  • 8
  • 16