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

go mod tidy error #181

Closed
greyireland opened this issue Apr 6, 2022 · 8 comments · Fixed by #199
Closed

go mod tidy error #181

greyireland opened this issue Apr 6, 2022 · 8 comments · Fixed by #199
Labels
enhancement New feature or request

Comments

@greyireland
Copy link

go get github.com/ethereum/go-ethereum

run go mod tidy ,get this error

github.com/ethereum/go-ethereum/crypto imports
        github.com/btcsuite/btcd/btcec/v2/ecdsa tested by
        github.com/btcsuite/btcd/btcec/v2/ecdsa.test imports
        github.com/btcsuite/btcd/chaincfg/chainhash: ambiguous import: found package github.com/btcsuite/btcd/chaincfg/chainhash in multiple modules:
        github.com/btcsuite/btcd v0.21.0-beta (/Users/crx/go/pkg/mod/github.com/btcsuite/btcd@v0.21.0-beta/chaincfg/chainhash)
        github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0 (/Users/crx/go/pkg/mod/github.com/btcsuite/btcd/chaincfg/chainhash@v1.0.0)
@ferranbt
Copy link
Contributor

ferranbt commented Apr 6, 2022

go get github.com/ethereum/go-ethereum

What are you trying to do? This is not the go-ethereum repo.

@greyireland
Copy link
Author

I want to use both libraries, go Ethereum and ethgo, but their dependencies conflict

@ferranbt
Copy link
Contributor

ferranbt commented Apr 7, 2022

Do you have a repo to reproduce this? Which version of Go are you using? I tried it on a test repo and it does work.

@greyireland
Copy link
Author

main.go

package main

import (
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/crypto"
	"github.com/ethereum/go-ethereum/log"
	"github.com/umbracle/ethgo"
	"github.com/umbracle/ethgo/jsonrpc"
)

func main() {
	crypto.CreateAddress2(common.HexToAddress(""), [32]byte{}, nil)
	log.Debug("hello")
	_ = ethgo.HexToAddress("0x000")
	_, _ = jsonrpc.NewClient("")
}

go.mod

module github.com/greyireland/ethgo-demo

go 1.15

require (
	github.com/ethereum/go-ethereum v1.10.17
	github.com/google/go-cmp v0.5.6 // indirect
	github.com/umbracle/ethgo v0.1.0
	golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
)

@ferranbt
Copy link
Contributor

ferranbt commented Apr 7, 2022

I reproduced it. It happens when using the crypto package in Geth since we both import btcd package but with different versions (Geth uses a newer one). I will check if it is worth it the update.

On the meantime, you can use version v1.10.16 of Geth which uses the same library as ethgo.

@ferranbt ferranbt added enhancement New feature or request and removed waiting-reply labels Apr 7, 2022
@greyireland
Copy link
Author

If you can't guarantee compatibility with the latest Ethereum, it's difficult for newcomers to use it.
So it is worth it the update~

@ferranbt
Copy link
Contributor

It seems to be some type of dependency error being tracked here. I tried a couple of iterations without success. I will wait for some possible PRs on the geth side.

What are you trying to do with the library that requires interactions with go-ethereum? Ideally, it is a full replacement and you do not need both at the same time.

@chappjc
Copy link

chappjc commented Apr 18, 2022

The following is a crummy solution, but the only thing that seems to get past the "ambiguous import" error caused by the github.com/btcsuite/btcd/chaincfg/chainhash module that also exists as the chaincfg/chainhash package in the github.com/btcsuite/btcd module (two different modules providing the same package import path, hence the issue), is all of the following:

  • specify go 1.17 in go.mod
  • include require github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect to disambiguate
  • go mod tidy -compat=1.17

It seems that when the chainhash module was created for use in the new btcec/v2 module, this problem wasn't anticipated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants