dpfqy5976
dpfqy5976
采纳率100%
2019-09-19 14:00

go mod无法找到依赖项的版本v0.0.0-00010101000000-000000000000

已采纳

我试图通过Go mod下载项目的所有依赖项;在CLI上执行Go mod供应商时会出现问题。产出如下:

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

导入库的代码如下:

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是我正在处理的包的名称:

go mod init krakengosdk

有解决办法吗?我已经研究了一段时间,但没有发现任何有用的东西。

更新:我已经将Go版本更新为1.13;似乎错误必须与“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
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • duandao8607 duandao8607 2年前

    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
    ", 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!

    点赞 评论 复制链接分享
  • dq201401 dq201401 2年前

    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.

    点赞 评论 复制链接分享