RiptimRip
RiptimRip

Reputation: 11

Go import error: invalid version unknow revision

Code, file structure on left and error

package main

import (
    "fmt"

    "github.com/cilium/cilium/api/v1/models"
    "github.com/cilium/cilium/pkg/client"
    log "github.com/sirupsen/logrus"
)

func main() {
    fmt.Println("Starting Application...")

    fmt.Println("Terminating Application...")
}

This is the error I get when I run: go run main.go

github.com/cilium/[email protected] requires github.com/optiopay/[email protected]: ivalid version: unknown revision 01ce283b732b

I am using go mod file for my dependencies and my go version is latest 1.14

I also checked my file structure and I already have [email protected] under pkg/mod/github.com/cilium

I tried adding github.com/optiopay/kafka under my import statement in my code but i get the same exact error still.

I have no idea how to fix this, I was googling but I could fin no definite or clear answer which worked. Any help appreicated.

Upvotes: 1

Views: 4465

Answers (3)

bitbuoy
bitbuoy

Reputation: 393

Error - the version that go is trying to pull for that specific module that imports it is either outdated or invalid.

Solution - For example in my case i was getting this error below:

go: downloading github.com/myk4040okothogodo/tutorial/gen/go/proto/books v0.0.0-00010101000000-000000000000
github.com/myk4040okothogodo/tutorial/books imports
    github.com/myk4040okothogodo/tutorial/books/server imports
    github.com/myk4040okothogodo/tutorial/gen/go/proto/books: github.com/myk4040okothogodo/tutorial/gen/go/proto/[email protected]: invalid version: unknown revision 000000000000

as you can see above my module "github.com/myk4040okothogodo/tutorial/books/server" imports another module "github.com/myk4040okothogodo/tutorial/gen/go/proto/books:" this import throws the error above, so i go to my go.mod file and make the following changes:

 1 module github.com/myk4040okothogodo/tutorial/books/server                                                                                                           
  2 
  3 go 1.18
  4 
  5 replace github.com/myk4040okothogodo/tutorial/db => ../../db
  6 
  7 replace github.com/myk4040okothogodo/tutorial/gen/go/proto/books => ../../gen/go/proto/books
  8 
  9 require (
 10   github.com/arangodb/go-driver v1.3.2
 11   github.com/myk4040okothogodo/tutorial/db v0.0.0-00010101000000-000000000000
 12   github.com/myk4040okothogodo/tutorial/gen/go/proto/books latest
 13   google.golang.org/grpc v1.47.0
 14 )

check above in line 12 where i put "latest" instead of the version number i.e "v0.0.0...."

I save the file and then i run "go mod tidy"

The compiler then changes the "latest" designation to an up to date version,i.e it will look as below after running the mod tidy command.

1 module github.com/myk4040okothogodo/tutorial/books/server                                                                                                           
  2 
  3 go 1.18
  4 
  5 replace github.com/myk4040okothogodo/tutorial/db => ../../db
  6 
  7 replace github.com/myk4040okothogodo/tutorial/gen/go/proto/books => ../../gen/go/proto/books
  8 
  9 require (
 10   github.com/arangodb/go-driver v1.3.2
 11   github.com/myk4040okothogodo/tutorial/db v0.0.0-00010101000000-000000000000
 12   github.com/myk4040okothogodo/tutorial/gen/go/proto/books v0.0.0-20220601171028-60237b9c9583
 13   google.golang.org/grpc v1.47.0
 14 )

PS: check the package where i make the changes, dont change the wrong imports

Upvotes: 0

Harsh Pandey
Harsh Pandey

Reputation: 31

seems optiopay/kafka is your private repo. You can configure ssh with git. and set your url in git config to use ssh instead of https.

Steps:

  1. configure ssh (if not already done)
  2. update git config -> git config --system url."[email protected]:".insteadOf "https://github.com/"

Upvotes: 0

Rolinh
Rolinh

Reputation: 1419

You are seeing this error because replace directives in go.mod are ignored by go mod/go get and the go.mod file of Cilium v1.7.2 contains many replace directives. To workaround this issue, replicate the replace directives of the version of Cilium that you are trying to import into your own go.mod file. An example for Cilium v1.7 can be found in this repository.

Upvotes: 1

Related Questions