Prevent Goland from automatically deleting unfinished code
In the Actions on Save setting, turn off Reformat Code, then in the File Watchers setting, add go fmt — this works better than the IDE's built-in Reformat.
I updated to Go 1.22, which seems to have updated go fmt as well; the above setting sometimes doesn't work, and it might be a Goland bug.