Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go/internal/modget: incompatible successes and failures #44952

Closed
carnott-snap opened this issue Mar 11, 2021 · 2 comments
Closed

cmd/go/internal/modget: incompatible successes and failures #44952

carnott-snap opened this issue Mar 11, 2021 · 2 comments

Comments

@carnott-snap
Copy link

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

[user@localhost ~]$ go version
go version go1.16 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
[user@localhost ~]$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY="*.sc-corp.net"
GONOSUMDB="*.sc-corp.net"
GOOS="linux"
GOPATH="/home/user/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/user/.local/share/umake/go/go-lang"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/user/.local/share/umake/go/go-lang/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/test/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build698062687=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Create the following go.mod file:

module test
  
go 1.16

require k8s.io/client-go v12.0.0+incompatible

Create the following main.go file:

package main
  
import (
        "fmt"

        "k8s.io/client-go/pkg/version"
)

func main() { fmt.Println(version.Get()) }
go mod download: k8s.io/client-go@v12.0.0+incompatible: invalid version: +incompatible suffix not allowed: module contains a go.mod file, so semantic import versioning is required
[user@localhost trash]$ go get k8s.io/client-go@v12.0.0
go get: k8s.io/client-go@v12.0.0: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v12
[user@localhost trash]$ go run .

What did you expect to see?

main.go:6:2: missing go.sum entry for module providing package k8s.io/client-go/pkg/version (imported by test); to add:
        go mod download k8s.io/client-go

What did you see instead?

While this may simply be more fallout from #34330, it seems like there is more going on. The fact that I am advised to go get test, a stdlib package, is maddenly confusing. Then it actually succeeds in injecting the incompatible version into my go.sum.

main.go:6:2: missing go.sum entry for module providing package k8s.io/client-go/pkg/version (imported by test); to add:
        go get test
[user@localhost trash]$ go get test
go: warning: k8s.io/client-go@v12.0.0+incompatible: retracted by module author: pre-module versions are obsolete
go: to switch to the latest unretracted version, run:
        go get k8s.io/client-go@latest
[user@localhost trash]$ go run .
v0.0.0-master+$Format:%h$
@bcmills
Copy link
Contributor

bcmills commented Mar 11, 2021

The fact that I am advised to go get test, a stdlib package, is maddenly confusing.

The stdlib package is testing.

test is what you named your module, and thus also the name of the package at the root of that module. (We perhaps could have suggested go get . instead, but that would require some extra reverse-mapping.)

@bcmills
Copy link
Contributor

bcmills commented Mar 11, 2021

Duplicate of #34330

@bcmills bcmills marked this as a duplicate of #34330 Mar 11, 2021
@bcmills bcmills closed this as completed Mar 11, 2021
@golang golang locked and limited conversation to collaborators Mar 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants