Use the goimports library rather than starting a process.

Thanks to @nf for making this possible.