Create getters and setters for struct fields

Generate the support code to access fields indirectly, via getters and setters

Do you need to access your struct fields via getters and setters? Add all the boilerplate code you need using the dedicated Generate getter and setter action.

How to use: Select a struct type, then press ⌥⏎ (macOS) / Alt+Enter (Windows/Linux) and choose Generate getter and setter from the list of available actions.

Choose which fields should have these methods generated, then press OK to generate them.

Choose the receiver name and receiver type then continue working on your code as usual.

Pro tip: You can choose either all fields, or select the individual fields that need to have these methods generated.

Related Resources

Improve Code Readability and Navigation
Discover how to manage code visibility with code folding in Go
Create a function in another package
Type a non-existing function name and generate its implementation in a package of your choice
Empower your `Printf`-like functions with coding assistance
Provide hints and highlights for message formats in custom `Printf`-like functions