Go 1.18 migration issues — Cannot convert 'nil' to type 'any'
Asked Answered
T

1

7

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?

Tips answered 30/3, 2022 at 11:11 Comment(0)
T
12

The issue is with the IDE. IntelliJ Goland 2021.2.4

I can build the code from the command line and in the playground.

Tips answered 30/3, 2022 at 11:20 Comment(2)
Is there a fix/update for the IDE? Or a gopls update perhaps?Diskson
Yes, the fix is included in the newer versions of GoLand, e.g. 2021.3.4 or the EAP build.Derogate

© 2022 - 2024 — McMap. All rights reserved.