Intellij IDEA: Running your own Go programs against editor text

In this post, I’ll describe one approach to running programs written in Go against text in the IDEA editor. This same approach applies to any Jetbrains IDE, such as PyCharm or WebStorm. Admittedly, this is niche. Tracking time at work Number 1: Every few weeks, I need to submit a virtual time card. If I work over 40 hours, I need to note that for comp time. If I work under 40 hours, I need to fill it in with PTO. Number 2: I work on several projects, and I need to track what percentage of my time I devote to … Continue reading Intellij IDEA: Running your own Go programs against editor text

Intellij IDEA: Run goimports on file save

goimports is a Go tool to remove unused and add missing imports. It also formats your code the same as go fmt. This is one solution for running goimports when saving *.go files in Intellij IDEA. If you have a better way (not involving snark about emacs), please comment. Assumptions You have goimports installed. If not, install with: go get code.google.com/p/go.tools/cmd/goimports You’re probably using the golang plugin. That plugin isn’t necessary for this goimports-on-save business, but if you’re using Intellij to write Go code then you might as well use the plugin, too. Big Picture Create a shell script to run goimports against … Continue reading Intellij IDEA: Run goimports on file save