I am still going through some Go tutorials. I am using Emacs as my editor.
There are some things that the go mode does not handle well; I don’t know if this is a shortcoming in the mode, or if I am using an old version, or if there is some conflict with another mode I am using. It’s actually a minor point.
It does not indent switch statements the way I want. All the “case” statements and everything inside them is indented as far as the “switch”. Hitting tab does not work. I have to hit “space” for every line. It gets pretty tedious.
But I found a way to do it:
- set-mark-command (C-@) and highlight the region
- indent-rigidly (C-x TAB)
- hit the arrow key as many times as I need. This will indent all the lines the same amount.
I also learned something about opening files. I had a directory with a file called “time.go” and “showtime.go”. When I tried find-file (C-x C-f), or switch-to-buffer (C-x b), it kept picking up “showtime.go”, even though I wanted “time.go”. I was able to open “time.go” with find-alternate-file (C-x C-v). Then I had to re-open “showtime.go”. It’s not a perfect solution, but it worked for me.
These commands are not unique to the Go mode.
Image from a late 9th or early 10th century Gospel manuscript made at the monastery of Saint Gall in eastern Switzerland, manuscript housed at Bavarian State Library, webpage information here, image from World Document Library, image assumed allowed under Fair Use.