Go: cmd/go: Can't `go get github.com/augustoroman/v8`

Created on 27 Oct 2018  ยท  12Comments  ยท  Source: golang/go

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

$ go version
go version go1.11.1 darwin/amd64

Does this issue reproduce with the latest release?

I think I have the latest release

What operating system and processor architecture are you using (go env)?

macOS 10.13.4

What did you do?

$ go get -v github.com/augustoroman/v8
go: finding github.com/augustoroman/v8 latest
Fetching https://github.com?go-get=1
Parsing meta tags from https://github.com?go-get=1 (status code 200)
go get github.com/augustoroman/v8: no matching versions for query "latest"
Executed from a directory outside my $GOPATH containing `go.mod`

What did you expect to see?

I expected the v8 package to be downloaded and installed.

What did you see instead?

The output from the command above.

I originally posted about this in #27215, but was asked to create a separate issue, because this might be a problem where go sees the package name (v8) as a version indicator.

Environment:

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/frederikcreemers/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/frederikcreemers/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/frederikcreemers/dev/marvin/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/q_/wgr019b53rx9b2lr3y7867bm0000gn/T/go-build238395171=/tmp/go-build -gno-record-gcc-switches -fno-common"

GO111MODULES is not set.

FrozenDueToAge NeedsInvestigation modules

Most helpful comment

One thing I wanted to add for anyone coming across this issue is that I found out that if I go get -d gopkg.in/augustoroman/v8.v1 everything works fine in Go 1.12.

All 12 comments

I've confirmed that the /v8 in the path is the problem. I've created a fork at github.com/bigblind/v-eight, and that works perfectly.

@bcmills @rsc

I've tried coding a script using the GitHub regex (see https://go.googlesource.com/go/+/go1.11.1/src/cmd/go/internal/get/vcs.go#983).

package main

import "regexp"
import "fmt"

func main() {
    var kregexp *regexp.Regexp
    reg := 
`^(?P<root>github\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[\p{L}0-9_.\-]+)*$`

    kregexp = regexp.MustCompile(reg)
    firstMatch, secondMatch := kregexp.FindStringSubmatch("github.com/hearot/ArgoScuolaNext-Go"), 
kregexp.FindStringSubmatch("github.com/augustoroman/v8")

    firstMatchMap := map[string]string{}
    secondMatchMap := map[string]string{}

    for i, name := range kregexp.SubexpNames() {
        if name != "" && firstMatchMap[name] == "" {
            firstMatchMap[name] = firstMatch[i]
        }
    }

    for i, name := range kregexp.SubexpNames() {
        if name != "" && secondMatchMap[name] == "" {
            secondMatchMap[name] = secondMatch[i]
        }
    }

    fmt.Printf("First match: %s", firstMatchMap)
    fmt.Println()
    fmt.Printf("Second match: %s", secondMatchMap)
}

And I got this:

First match: map[root:github.com/hearot/ArgoScuolaNext-Go]
Second match: map[root:github.com/augustoroman/v8]

That regex works perfectly, there are no errors. So, I've also tried to do the go get -v github.com/augustoroman/v8 command and I've got no errors, everything has been installed successfully.

/cc @myitcv

Last time I saw comment on this, @rsc's thoughts were that such a case is extremely rare, and hence renaming the package is the solution (per @bigblind):

https://go-review.googlesource.com/c/vgo/+/122399/5/vendor/cmd/go/internal/modfetch/coderepo.go#307

Yes, sorry. My suggestion is v8js.

This is not extremely rare. This will effect like half of the K8s libraries.

The Kubernetes project uses versions as their package names today, and they have some reaching the point of v2. This suspect this issue could cause major disruptions in the Kubernetes ecosystem if they needed to change how code is structured or named, especially in relation to people trying use it with modules. Based on recent experiences with gofrs/uuid around SIV, I anticipate this will not be a great experience without fully investigating the ramifications of this change in the ecosystem.

Can we please have this issue re-opened, is there anyone from the Kubernetes project who we can loop-in for an official perspective as well?

@theckman, @mattmoor, note that the restriction is on module paths that end in /vN, not package paths.

https://godoc.org/?q=k8s.io+v2 doesn't show any packages ending in /v2 at all, but it appears that none of the packages in https://godoc.org/?q=k8s.io+v1 would violate that restriction either.

@theckman , @mattmoor, to slightly expand on that comment from @bcmills (with the intent of trying to explain at least briefly -- "well, what is the difference between a module path vs. a package path?")

For most projects, the _module path_ is the repo (e.g., github.com/my/repo).

For example, if you are creating a module for a repository github.com/my/repo that will contain two packages with import paths github.com/my/repo/foo and github.com/my/repo/bar, then the first line in your go.mod file typically would declare your module path as module github.com/my/repo, and the corresponding on-disk structure could be:

repo/
โ”œโ”€โ”€ go.mod
โ”œโ”€โ”€ bar
โ”‚ย ย  โ””โ”€โ”€ bar.go
โ””โ”€โ”€ foo
    โ””โ”€โ”€ foo.go

More generally, the import paths for all packages in a module share the module path as a common prefix. A module declares its identity in its go.mod via the module directive, where that first line in the go.mod (starting with the word module) provides the declaration of the module path.

thanks, that is definitely less worrying.

One thing I wanted to add for anyone coming across this issue is that I found out that if I go get -d gopkg.in/augustoroman/v8.v1 everything works fine in Go 1.12.

Was this page helpful?
0 / 5 - 0 ratings