build command-line-arguments: cannot load github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v2.0.0+incompatible), but does not contain package github.com/gomodule/redigo
can anyone help?
go version 1.13.11
Are you using go mod, if not then that should fix this
Are you using go mod, if not then that should fix this
yes, i am using go mod. does any other methods to fix this?
What does your go.mod look like for redigo?
It looks like the existence of the tag v2.0.0 which doesn't have a go.mod (and seems pretty old?) causes Go to fail to pick up the current 1.x versions that have go.mod files. Without explicitly adding redigo to go.mod, Go auto-adds the following:
github.com/gomodule/redigo v2.0.0+incompatible
Try removing any mention of github.com/gomodule/redigo from your go.mod and then running:
go get github.com/gomodule/redigo/redis
go mod init
go mod tidy
go get github.com/gomodule/redigo/redis@latest
Your commands aren't quite right there @bensema it should be something like:
$ go mod init github.com/stevenh/redis-test
go: creating new go.mod: module github.com/stevenh/redis-test
$ go get github.com/gomodule/redigo/redis
go: downloading github.com/gomodule/redigo v1.8.2
go: downloading github.com/gomodule/redigo/redis v0.0.0-do-not-use
go: found github.com/gomodule/redigo/redis in github.com/gomodule/redigo v1.8.2
$ more go.mod
module github.com/steveh/redis-test
go 1.14
require github.com/gomodule/redigo v1.8.2 // indirect
Using go get before ever using the module is one workaround, but since module auto-discovery is broken for this module due to the v2.0.0 tag (and people might go build before realizing this is a problem), I'd recommend the preferred workaround be to tell people to explicitly add the module and version to the go.mod file.
Since you probably can't delete the v2.0.0 tag without breaking projects already pointed at it, perhaps a more long-term fix would be to add a v2.0.1 that does have a go.mod so that auto discovery won't choose 2.x versions without a /v2 in the import path?
Testing here I didn't need to use go get either e.g.:
```
go mod init github.com/stevenh/redis-test
go: creating new go.mod: module github.com/stevenh/redis-test
vi main.go
Save with content:
```go
package main
import "fmt"
func main() {
p := redis.Pool{}
fmt.Println("vim-go", p)
}
go-vim picked up and added redis to imports and go.mod
more go.mod
module github.com/stevenh/redis-test
go 1.14
require github.com/gomodule/redigo v1.8.2
I believe this has been answered, so going to close. Please do reopen if this is not the case.
o, I got same problem
I have tried go clean -modcache, than use go mod tidy, but still return error: github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v2.0.0+incompatible), but does not contain package github.com/gomodule/redigo
By the way, go get github.com/gomodule/redigo/redis@latest was worked before go mod tidy with no error
I also tried github.com/gomodule/redigo v1.8.3 in go.mod, then:
PS F:\work\home\redis-cli> go mod tidy
go: downloading github.com/gomodule/redigo v1.8.3
go: extracting github.com/gomodule/redigo v1.8.3
redis-cli/cmd imports
github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v2.0.0+incompatible), but does not contain package github.com/gomodule/redigo
PS F:\work\home\redis-cli> go mod tidy
redis-cli/cmd imports
github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v2.0.0+incompatible), but does not contain package github.com/gomodule/redigo
PS F:\work\home\redis-cli>
PS F:\work\home\redis-cli>
PS F:\work\home\redis-cli> go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOENV=dev
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=github.com
set GONOSUMDB=github.com
set GOOS=windows
set GOPATH=F:\work\base_env\go-path
set GOPRIVATE=github.com
set GOPROXY=https://goproxy.cn,direct
set GOROOT=F:\work\base_env\go-1.13.12
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=F:\work\base_env\go-1.13.12\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=F:\work\home\redis-cli\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=E:\Temp\go-build435141374=/tmp/go-build -gno-record-gcc-switches
so, how to fix it??
I can't reproduce this here, but I have go1.15.5
Have you tried using the latest version of golang in case its a bug in go module support?
Also what does go.mod look like?
try new version of golang? em..., maybe it's worth to try
but when i google this problem at i got this error first time, i found many people have same problem with different version of golang, the way they shared who resolved this problem can't fix my problem. -_-|||
my go.mod is here
module redis-cli
go 1.13
require (
github.com/go-redis/redis/v8 v8.4.10
github.com/gomodule/redigo v1.8.3 // indirect
github.com/spf13/cobra v1.1.1
)
If it's a bug in the module support of the version you're using update might fix it.
The other thing to try is: go clean (without the -modcache) to see if there is something else stale which is causing bad behaviour
PS F:\work\home\redis-cli-test> go version
go version go1.15.7 windows/amd64
PS F:\work\home\redis-cli-test> go mod tidy
go: finding module for package github.com/gomodule/redigo
redis-cli-test imports
github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v1.8.3), but does not contain package github.com/gomodule/redigo
PS F:\work\home\redis-cli-test>
PS F:\work\home\redis-cli-test>
PS F:\work\home\redis-cli-test>
PS F:\work\home\redis-cli-test> go clean
go: finding module for package github.com/gomodule/redigo
PS F:\work\home\redis-cli-test>
PS F:\work\home\redis-cli-test> go mod tidy
go: finding module for package github.com/gomodule/redigo
redis-cli-test imports
github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v1.8.3), but does not contain package github.com/gomodule/redigo
PS F:\work\home\redis-cli-test>
I think it's not a bug in the module, and of course not my code's bug, because I just import redigo without any other code
// main.go
package main
import (
"fmt"
_ "github.com/gomodule/redigo"
)
func main() {
fmt.Println(`hello world`)
}
// go.mod
module redis-cli-test
go 1.15
require github.com/gomodule/redigo v1.8.3 // indirect
Is my computer broken???
PS F:\work\home\redis-cli-test> go version go version go1.15.7 windows/amd64 PS F:\work\home\redis-cli-test> go mod tidy go: finding module for package github.com/gomodule/redigo redis-cli-test imports github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v1.8.3), but does not contain package github.com/gomodule/redigo PS F:\work\home\redis-cli-test> PS F:\work\home\redis-cli-test> PS F:\work\home\redis-cli-test> PS F:\work\home\redis-cli-test> go clean go: finding module for package github.com/gomodule/redigo PS F:\work\home\redis-cli-test> PS F:\work\home\redis-cli-test> go mod tidy go: finding module for package github.com/gomodule/redigo redis-cli-test imports github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v1.8.3), but does not contain package github.com/gomodule/redigo PS F:\work\home\redis-cli-test>I think it's not a bug in the module, and of course not my code's bug, because I just import
redigowithout any other code// main.go package main import ( "fmt" _ "github.com/gomodule/redigo" ) func main() { fmt.Println(`hello world`) } // go.mod module redis-cli-test go 1.15 require github.com/gomodule/redigo v1.8.3 // indirectIs my computer broken???
I tried it in my Ubuntu 20 in VMware, it is still return this error
juwell@juwell-virtual-machine:~/work/redis-cli-test$ go mod init redis-cli-test
go: creating new go.mod: module redis-cli-test
juwell@juwell-virtual-machine:~/work/redis-cli-test$
juwell@juwell-virtual-machine:~/work/redis-cli-test$
juwell@juwell-virtual-machine:~/work/redis-cli-test$ go mod tidy
go: finding module for package github.com/gomodule/redigo
go: downloading github.com/gomodule/redigo v1.8.3
redis-cli-test imports
github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v1.8.3), but does not contain package github.com/gomodule/redigo
juwell@juwell-virtual-machine:~/work/redis-cli-test$ ^C
juwell@juwell-virtual-machine:~/work/redis-cli-test$ go mod tidy
go: finding module for package github.com/gomodule/redigo
redis-cli-test imports
github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v1.8.3), but does not contain package github.com/gomodule/redigo
juwell@juwell-virtual-machine:~/work/redis-cli-test$ go version
go version go1.15.7 linux/amd64
juwell@juwell-virtual-machine:~/work/redis-cli-test$ go clean
go: finding module for package github.com/gomodule/redigo
juwell@juwell-virtual-machine:~/work/redis-cli-test$ go mod tidy
go: finding module for package github.com/gomodule/redigo
redis-cli-test imports
github.com/gomodule/redigo: module github.com/gomodule/redigo@latest found (v1.8.3), but does not contain package github.com/gomodule/redigo
Your main.go is invalid as the package that gets used is github.com/gomodule/redigo/redis not github.com/gomodule/redigo.
Using your example I also see:
go build
go: finding module for package github.com/gomodule/redigo
main.go:6:2: module github.com/gomodule/redigo@latest found (v1.8.3), but does not contain package github.com/gomodule/redigo
Correcting main.go results in success
package main
import (
"fmt"
_ "github.com/gomodule/redigo/redis"
)
func main() {
fmt.Println(`hello world`)
}
go build
go: finding module for package github.com/gomodule/redigo/redis
go: found github.com/gomodule/redigo/redis in github.com/gomodule/redigo v1.8.3
Your
main.gois invalid as the package that gets used isgithub.com/gomodule/redigo/redisnotgithub.com/gomodule/redigo.Using your example I also see:
go build go: finding module for package github.com/gomodule/redigo main.go:6:2: module github.com/gomodule/redigo@latest found (v1.8.3), but does not contain package github.com/gomodule/redigoCorrecting
main.goresults in successpackage main import ( "fmt" _ "github.com/gomodule/redigo/redis" ) func main() { fmt.Println(`hello world`) }go build go: finding module for package github.com/gomodule/redigo/redis go: found github.com/gomodule/redigo/redis in github.com/gomodule/redigo v1.8.3
waow, it's fixed me, thank you~~~ 馃憤