1

when I execute below cmd:

go get k8s.io/client-go@v12.0.0

it tells me: "go: k8s.io/client-go@v12.0.0: invalid version: module contains a go.mod file, so module path must match major version ("k8s.io/client-go/v12")"

ok, then I changed the cmd to this:

go get k8s.io/client-go@v12.0.0+incompatible

then again, it still tells me the same error: go: k8s.io/client-go@v12.0.0+incompatible: invalid version: module contains a go.mod file, so module path must match major version ("k8s.io/client-go/v12")

one interesting thing puzzles me that if I add require k8s.io/client-go v12.0.0+incompatible to go.mod and then execute go mod tidy, then client-go v12.0.0 will be downloaded correctly.

My question is: how can I download this specific version of client-go via go get??

Go Version: v1.18

Wallace
  • 561
  • 2
  • 21
  • 54

2 Answers2

1

I used the go install command to download client-go

Here are two examples to install the latest or specific version.

go install k8s.io/client-go@latest

go install k8s.io/client-go@v0.25.3

See client-go installation section for more help, client-go install

-2

how can I download this specific version of client-go via go get

Not at all.

go get is for adding dependencies to your project.

To download source code in a certain version from the internet use git clone and git checkout.

Volker
  • 40,468
  • 7
  • 81
  • 87
  • adding dependency is only one of its job. According to this "https://go.dev/ref/mod#go-get": "The go get command updates module dependencies in the go.mod file for the main module, then builds and installs packages listed on the command line." so the Go Get tool does download packages and install them. – Wallace Oct 23 '22 at 07:34
  • "Go Get tool does download packages and install them" that's completely secondary to its one and only relevant function: adding a dependency. (Adding a dependency that is not accessable cannot be added.) – Volker Oct 23 '22 at 07:37
  • ok, but why it worked if I edited the go.mod by manually adding "require k8s.io/client-go v12.0.0+incompatible" there? (go mod tidy works correctly) – Wallace Oct 23 '22 at 07:42