go-sqlite3: cannot load github.com/mattn/go-sqlite3: module github.com/mattn/go-sqlite3@latest (v2.0.0+incompatible) found, but does not contain package github.com/mattn/go-sqlite3

This package doesn’t seem to work with go modules. Here’s a simple recipe in Docker, to make it easy to reproduce. Please tell me what I’m doing wrong:

$ docker run -it --rm golang:alpine
/go # apk add build-base
...
/go # mkdir /src
/go # cd /src
/src # cat - > main.go
package main
import (
        "fmt"
	_ "github.com/mattn/go-sqlite3"
)
func main() {
	fmt.Println("Hello world!")
}
/src # export CGO_ENABLED=1
/src # go mod init example.com
go: creating new go.mod: module example.com
/src # go get github.com/mattn/go-sqlite3
go: finding github.com/mattn/go-sqlite3 v2.0.0+incompatible
go: downloading github.com/mattn/go-sqlite3 v2.0.0+incompatible
go: extracting github.com/mattn/go-sqlite3 v2.0.0+incompatible
/src # go run .
build example.com: cannot load github.com/mattn/go-sqlite3: module github.com/mattn/go-sqlite3@latest (v2.0.0+incompatible) found, but does not contain package github.com/mattn/go-sqlite3

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 10
  • Comments: 29 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry, but I will NOT release v2.0.1 or higher just to fix this issue.

I will keep this issue open until we will find a fundamental solution for this issue.

Now tagged v2.0.1. Your issues will be fixed with go get -u github.com/mattn/go-sqlite3. However I don’t close this issue until https://github.com/golang/go/issues/35671 will be fixed.

@gdm85 or maybe you can just add github.com/mattn/go-sqlite3 to GOPRIVATE

@mattn the problem is that I run go get -u all once a week in order to update all my dependencies. I think it’s doing a query to proxy.golang.org, and it will see the invalid version.

IMO the simplest fix is

add github.com/mattn/go-sqlite3 to GOPRIVATE

If you want to solve this issue immediately, please try to do in your repository (Do NOT run it outside of your repository)

go get -u github.com/mattn/go-sqlite3@v1.12.0

@pierrre I think so too. But it means new users will always get the error?

I worked it around by appending to go.mod:

replace github.com/mattn/go-sqlite3 => ./vendor/github.com/mattn/go-sqlite3

Then cloning the repository locally and adding a go.mod in there (it can be created with go mod init github.com/mattn/go-sqlite3):

module github.com/mattn/go-sqlite3

go 1.12

I suggest adding the go.mod file here on go-sqlite3 for a longer term solution; on a side node, the proxy should be more explicit about its operations when building, but it’s not from what I can see.

Fixed.