tensor-programming / golang-blockchain

266 stars 123 forks source link

having issue in item.Value() in blockchain/blockchain.go #5

Open laibleeds opened 3 years ago

laibleeds commented 3 years ago

image i can not resolve the error here, which says " cannot assign 1 values to 2 variables" & "too few arguments in call to item.Value"

please help me out with it, currently i'm using go version 1.15.8 on VScode

rishikeshkchapekar commented 3 years ago

I had the same problem. It seems BadgerDB Go package has updated since the video series was published, and the item.Value() syntax has changed

So I looked up the Badger docs, and fixed the code according to the latest version. So now the code looks this:

var encodedBlock []byte
err = item.Value(func(val []byte) error{
    encodedBlock = val
    return nil
})

You can see the latest docs here