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

cannot find package "github.com/cespare/xxhash/v2" #34

Closed
reneba opened this issue Dec 3, 2019 · 7 comments
Closed

cannot find package "github.com/cespare/xxhash/v2" #34

reneba opened this issue Dec 3, 2019 · 7 comments

Comments

@reneba
Copy link

reneba commented Dec 3, 2019

hi,

first. sorry for my english :)

I am relatively new to go programming. but I wanted to deal with it. I wanted to get the following code to work because I deal with go and go-ethereum.

But I always get the error below

Despite intensive google search and my meager english knowledge I could not find a solution. Unfortunately,
I do not know anybody who knows about go.

Maybe you can help me

Many thanks

--Error-
src\github.com\VictoriaMetrics\fastcache\bigcache.go:7:2: cannot find package "github.com/cespare/xxhash/v2" in any of: C:\Go\src\github.com\cespare\xxhash\v2 (from $GOROOT) C:\Users\go\src\github.com\cespare\xxhash\v2 (from $GOPATH)
--Code--
`package main

import (
"context"
"fmt"
"log"
"math"
"math/big"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"

)

func main() {
client, err := ethclient.Dial("https://mainnet.infura.io")
if err != nil {
log.Fatal(err)
}

account := common.HexToAddress("0x71c7656ec7ab88b098defb751b7401b5f6d8976f")
balance, err := client.BalanceAt(context.Background(), account, nil)
if err != nil {
    log.Fatal(err)
}
fmt.Println(balance) // 25893180161173005034

blockNumber := big.NewInt(5532993)
balanceAt, err := client.BalanceAt(context.Background(), account, blockNumber)
if err != nil {
    log.Fatal(err)
}
fmt.Println(balanceAt) // 25729324269165216042

fbalance := new(big.Float)
fbalance.SetString(balanceAt.String())
ethValue := new(big.Float).Quo(fbalance, big.NewFloat(math.Pow10(18)))
fmt.Println(ethValue) // 25.729324269165216041

pendingBalance, err := client.PendingBalanceAt(context.Background(), account)
fmt.Println(pendingBalance) // 25729324269165216042

}`

@Thiamath
Copy link

Thiamath commented Dec 4, 2019

Same here.
The Prometheus client since v1.2.0 is using your v2 package as a dependency and now is broken because of this.
https://github.com/prometheus/client_golang/blob/v1.2.0/go.mod

@superfell
Copy link

See #31 You need to be using go 1.11 or newer, what version of go are you running?

@cespare
Copy link
Owner

cespare commented Dec 5, 2019

@reneba as @superfell said, you need to be using a recent enough version of Go that it has at least "minimal module compatibility". See the README. (You do not actually even need 1.11 -- 1.9.7+ and 1.10.3+ have the functionality backported.)

The key thing is that these versions of Go understand that when they are looking for /v2, they should find that in a v2 branch.

@Thiamath no, it is not "broken". See my explanation above.

In fact, I just confirmed that I can build all the packages in https://github.com/prometheus/client_golang using Go 1.9.7.

By the way, any Go project that wants to use my package is free to use the v1 module (github.com/cespare/xxhash). That will work even with ancient versions of Go. v1 works just fine (v2 just has some API improvements). The choice to use v2 is taken by projects that depend on my package, not by me.

@cespare cespare closed this as completed Dec 5, 2019
@cespare cespare pinned this issue Dec 5, 2019
@Thiamath
Copy link

Thiamath commented Dec 5, 2019

Sorry for the delay...
I'm using go version 1.13.1
Maybe the problem is that my project is using dep to manage dependencies instead of go modules?
If that's the case, I'm not sure about how to fix that... I'm still a n00b in golang.

@cespare
Copy link
Owner

cespare commented Dec 18, 2019

Yes, dep does not support v2+ modules.

@rohankeskar19
Copy link

Sorry for the delay...
I'm using go version 1.13.1
Maybe the problem is that my project is using dep to manage dependencies instead of go modules?
If that's the case, I'm not sure about how to fix that... I'm still a n00b in golang.

Use

go env

if

GO111MODULE

is not set
then use

set GO111MODULE=on

then try again

@Ericwonne
Copy link

@rohankeskar19 Thank you for saving my day! [Rose]

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

No branches or pull requests

6 participants