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


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?


The issue is with the IDE. IntelliJ Goland 2021.2.4

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

Answered By – Raghu

Answer Checked By – Willingham (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.