Option to automatically add the keyed parameters of a struct

Completed

Hi all,

Let's say I got the following struct:

type Bh struct {
da string
sne string
}

When I want an instance of it, I can do both a := Bh{"x", "y"} but also b: = Bh{da:"x", sne:"y"}

The second option is better and a must in many cases (like with protobuf).

I tried to find a way to make Goland autocomplete Bh directly to Bh{da: sne:} in order for me to just fill in the details but with no avail (the closest I got is an auto complete feature for each parameter).

Is there a way to do that?

Thanks!

0
2 comments

Hi,

For empty initializer you can invoke `Fill struct` action via Alt+Enter menu.

For filled initializer without structure keys, you can invoke `Add keys and delete zero values` via Alt+Enter menu.

Is that you're looking for?

1
Avatar
Permanently deleted user

Indeed it is! Thank you Alexander! :)

0

Please sign in to leave a comment.