x/tools/gopls: add some error handle postfix completion (rr, reterr, varCheckError) #64178
Labels
gopls
Issues related to the Go language server, gopls.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
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.
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.
reterr

Sometimes when calling a function, you just need to check if there is an error.
varCheckError

Get the return value after calling the function and check for errors. This is a more general version compared to reterr.
The text was updated successfully, but these errors were encountered: