Skip to content

x/tools/gopls: add some error handle postfix completion (rr, reterr, varCheckError) #64178

@rogeryk

Description

@rogeryk

Describe the solution you'd like

Go requires that you must explicit error handling, so many times you must write some boring error handling code, and postfix completion can ease the pain.
rr
In most cases, we just need check the error and return it.
Kapture 2023-11-15 at 22 47 13
This also depends on the return parameters of the current function, for example, when the function has return values other than error, the return values other than error will use default values.
Kapture 2023-11-15 at 22 49 10

reterr
Sometimes when calling a function, you just need to check if there is an error.
Kapture 2023-11-15 at 22 55 42

varCheckError
Get the return value after calling the function and check for errors. This is a more general version compared to reterr.
Kapture 2023-11-15 at 22 58 52

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions