Go autocomplete - disable names of return types
When I type a function parameter in Go, the autocomplete feature automatically inserts the return type names.
For example:
SomeFuncWithFuncParameter(func(ctx context.Context, key string) (type *grpc.MyType, e error) {
}),
I want the return types of the param function to be unnamed by default. It should be just (*grpc.MyType, error)
Is it possible to achieve this?
Thanks
Please sign in to leave a comment.
Completion repeats the expected type. If `SomeFuncWithFuncParameter` won't have names of return parameters in its functional parameter, completion won't add them by default.
Hi Alexander, it looks like this is not the case. The declaration of my function does not specify named return types, but the autocomplete adds them anyway.
Also, I recently updated to Intellij version 18.3.x from 18.1.x I didn't have this issue before.
What is even more annoying is that the autocomplete adds named return types whenever I have more than one return type in any function.
Let's say that I have a func declaration as the following:
func (r *receiver) SomeNiceFunction(s string) (*package.TypeA, error) {
}
and I change the first return type to `*package.TypeB` then the autocomplete result is
func (r *receiver) SomeNiceFunction(s string) (typeB *package.TypeB, error) {
}
which the IDE will now mark as error, because one return type is named and the other is not.
This is extremely frustrating, since I have to go back and delete the name myself, or not use the autocomplete at all.
Now I get it. It's going to be fixed in the first 2019.1 eap. Until then, you can disable `Settings | Go | Suggest parameter name in completion`.
Hi Alexander,
> What is even more annoying is that the autocomplete adds named return types whenever I have more than one return type in any function.
I was able to solve this ^ with your suggestion.
I'm looking forward to the fix to the other issue.
Thank you for your time
No problem.
Btw, GoLand 2019.1 EAP is published. Please take a look: https://www.jetbrains.com/go/nextversion/