4

I'm trying to download all of the dependencies of a project via go mod; the problem occurs when it comes to execute go mod vendor on the CLI. The output is as follows:

go: finding github.com/hyperledger/fabric-sdk-go v0.0.0-00010101000000-000000000000
go: github.com/hyperledger/fabric-sdk-go@v0.0.0-00010101000000-000000000000: unknown revision 000000000000
go: error loading module requirements

The code that imports the libraries is this:

import (    
    "github.com/hyperledger/fabric-sdk-go/pkg/client/ledger"
    "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt"
    "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
)

krakengosdk is the name of the package I'm working on:

go mod init krakengosdk

Any solution? I've been looking for any solution for a while, but I haven't came across anything useful.

EDIT: I've updated the go version to 1.13; it seems like the error has to be with "github.com/hyperledger/fabric-sdk-go/test/integration@v0.0.0-20190918153951-5d7ae7a5be8f":

go get -v github.com/hyperledger/fabric-sdk-go/test/integration@latest
go: finding github.com/hyperledger/fabric-sdk-go/test/integration latest
go get: github.com/hyperledger/fabric-sdk-go/test/integration@v0.0.0-20190918153951-5d7ae7a5be8f requires
    github.com/hyperledger/fabric-sdk-go@v0.0.0-00010101000000-000000000000: invalid version: unknown revision 000000000000
1
  • did you ever find a solution to this ?
    – bitbuoy
    May 16, 2022 at 17:10

5 Answers 5

5

Questions:

  1. What is your exact go.mod file?
  2. Do you have any replace directives for github.com/hyperledger/fabric-sdk-go?
  3. If you don't currently, did you at one time?

That long version v0.0.0-00010101000000-000000000000 is what usually shows up if you have a replace directive but don't have a corresponding require directive and the go command automatically adds a require directive for you using that long version.

That can be fine, but I wonder if you did something like added a replace, but then later removed the replace while leaving in place the long version v0.0.0-00010101000000-000000000000 in the require. Or something like that.

What happens if you:

  1. Remove any replace directives for github.com/hyperledger/fabric-sdk-go that you might have
  2. Change the require for github.com/hyperledger/fabric-sdk-go to be:
 require github.com/hyperledger/fabric-sdk-go latest
  1. Run go list -m all

Also, if not already, you should be using the latest release of Go 1.13, which fixes some bugs but also often has much better error messages.

4

This happened to me because of using replace flag and removing the replace flag. This can be corrected with use of below two commands.

go mod edit -droprequire=github.com/hyperledger/fabric-sdk-go

Above command drops the dependency

go mod tidy

Above command re-downloads the dependency.

1
  • Please make sure to use correct package name for as per your error. May 19, 2021 at 8:15
1

Proposed diagnostics

I suggest to try those commands in console (bash/dash/fish/zsh):


# 1. Create clean project 
$ mkdir /tmp/checkmods && cd /tmp/checkmods  # create clean directory
$ export GO111MODULES=on
$ go version # check that version 1.13
$ go mod init main # name of package does not matter here

# 2. Install packages, check output
$ go get -v github.com/hyperledger/fabric-sdk-go/pkg/client/ledger
$ go get -v github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt
$ go get -v github.com/hyperledger/fabric-sdk-go/pkg/fabsdk

# 3. Create main.go 
$ touch main.go
$ # edit main.go, add imported packages, import something from those packages
$ go mod vendor 
# Do you have problems here? 
# if you encounter problems: 
# - play around  with `go mod tidy`
# - look at `go.mod` and `go.sum`
# - `go mod graph/verify/why` - are your friends

Example of main.go:

package main

import (
    "fmt"
    "github.com/hyperledger/fabric-sdk-go/pkg/client/ledger"
    "github.com/hyperledger/fabric-sdk-go/pkg/client/resmgmt"
    "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
)

func main() {
    var (
        cln  &ledger.Client
        rsm  &resmgmt.Client
        fbs  &fabsdk.FabricSDK
    )
    fmt.Printf("%T %T %T\n", cln, rsm, fbs)
}

Analysis

If you encounter problems: explain on which line you encountered, what kind of problem.

If everything OK with clean start: look what is different between your project and clean start (diffs for go.sum & go.mod)

Good luck!

0
1

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/books@v0.0.0-00010101000000-000000000000: 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

0

I am not sure if this solution would work for everyone, but I just did go get PACKAGE_WITH_ISSUE, so in your case:

go get github.com/hyperledger/fabric-sdk-go

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.