英文:
Too many arguments in call during compilation
问题
我想在我的Go项目中使用一个包,但是由于以下错误,我甚至无法成功编译代码:
C:\Users\usr01\go\pkg\mod\github.com\alethio\web3-multicall-go@v0.0.15\multicall\viewcall.go:259:8: 赋值不匹配:1个变量,但wrapperArgs.Unpack返回2个值
C:\Users\usr01\go\pkg\mod\github.com\alethio\web3-multicall-go@v0.0.15\multicall\viewcall.go:259:37: 调用wrapperArgs.Unpack时参数过多
这发生在我使用go run
启动程序时,我认为是在编译过程中发生的,因为使用该包的代码没有被调用。我对这门语言还不熟悉,但我调查了一下,发现问题发生在属于web3-go-multicall包的viewcall.go文件的第259行之前。
问题发生在这里:
data, err := wrapperArgs.Unpack(rawBytes)
我不明白为什么会出现这个问题?因为返回的两个变量都被赋值给了data
和err
,所以assignment mismatch: 1 variable but wrapperArgs.Unpack returns 2 values
错误对我来说似乎是不正确的。
wrapperArgs := abi.Arguments{
{
Name: "BlockNumber",
Type: uint256Type,
},
{
Name: "Returns",
Type: returnType,
},
}
data, err := wrapperArgs.Unpack(rawBytes)
英文:
I would like to use a package in my Go project, but I can't even compile the code successfully because of the following error:
C:\Users\usr01\go\pkg\mod\github.com\alethio\web3-multicall-go@v0.0.15\multicall\viewcall.go:259:8: assignment mismatch: 1 variable but wrapperArgs.Unpack returns 2 values
C:\Users\usr01\go\pkg\mod\github.com\alethio\web3-multicall-go@v0.0.15\multicall\viewcall.go:259:37: too many arguments in call to wrapperArgs.Unpack
This happens when I start my program with go run
, I assume during the compilation because the code which uses the package doesn't get called. I am new to this language, but what I could investigate is the problem occurs before the 259. line of the viewcall.go file which belongs to the web3-go-multicall package.
This is where the problem occurs:
data, err := wrapperArgs.Unpack(rawBytes)
What I don't understand, why this issue happens anyway? Because both returned variables are assigned to data
and err
so the assignment mismatch: 1 variable but wrapperArgs.Unpack returns 2 values
error seems incorrect for me.
wrapperArgs := abi.Arguments{
{
Name: "BlockNumber",
Type: uint256Type,
},
{
Name: "Returns",
Type: returnType,
},
}
data, err := wrapperArgs.Unpack(rawBytes)
答案1
得分: 2
你已经将代码链接到主分支,但根据你提供的日志,你使用的是版本v0.0.15
。在该版本中,左侧只有一个参数,并且有两个参数传递给一个函数 - https://github.com/Alethio/web3-multicall-go/blob/v0.0.15/multicall/viewcall.go#L259
可能是两个库(github.com/Alethio/web3-multicall-go
和github.com/ethereum/go-ethereum
或其子库)的版本不兼容。
英文:
You have linked the code in master, but according to logs that you have provided you are on version v0.0.15
. And in that version there is only 1 argument on the left side and 2 arguments passed to a function - https://github.com/Alethio/web3-multicall-go/blob/v0.0.15/multicall/viewcall.go#L259
Probably 2 libraries (github.com/Alethio/web3-multicall-go
and github.com/ethereum/go-ethereum
or some child of that) have incompatible versions.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论