How to disable errors in VS Code (gopls) when writing code in go1.18beta?

Viewed 1710

Want to use go1.18beta for its generics feature to handle errors in a central function.

Error handling function example

func HandleError[T any](t T, err error) T {
    if err != nil {
        panic(err)
    }
    return t
}

The first error thrown is

expected '(', found '['s

The second error thrown is

not enough arguments in call to HandleError (compiler) (WrongArgCount)

I am aware that gopls is of go1.17 and that's why it's throwing errors but is there any way to disable these errors as we do in typescript?

1 Answers
Related