Go 1.18 迁移问题 ߞ无法转换“nil”;输入“任何”
我将代码库更新为 Go 1.18。一切看起来都很棒,但在一些地方,我发现了以下问题。
defer func() {
if e := recover() ; e!=nil {
...
}
}()
编译失败并显示:
无法将“nil”转换为“any”类型
相同的代码在 Go 1.17 中运行良好。根据 Go 1.18 发行说明,any
是 interface{}
(泛型)的内置类型别名,
这是怎么回事?
I updated my codebase to Go 1.18. It all looks great, but in a few places, I found the following issues.
defer func() {
if e := recover() ; e!=nil {
...
}
}()
Compilation is failing with:
Cannot convert 'nil' to type 'any'
The same code was working good with Go 1.17. Based on Go 1.18 Release notes, any
is a built-in type of alias for interface{}
(Generics)
What is going on?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题出在 IDE 上。 IntelliJ Goland 2021.2.4
我可以从命令行和 playground 构建代码。
The issue is with the IDE. IntelliJ Goland 2021.2.4
I can build the code from the command line and in the playground.