Skip to content

Instantly share code, notes, and snippets.

@qxxt
Created July 8, 2023 07:42
Show Gist options
  • Save qxxt/9775c587db0930d883dd7a2f6b44f9a8 to your computer and use it in GitHub Desktop.
Save qxxt/9775c587db0930d883dd7a2f6b44f9a8 to your computer and use it in GitHub Desktop.
Simple hack for calling goimports on buffer on Emacs.
(defun goimports-buffer ()
"Format current buffer with goimports."
(interactive)
(let ((gofmt-command-bak gofmt-command)
(gofmt-args-bak gofmt-args))
(setq gofmt-command "goimports"
gofmt-args nil)
(with-current-buffer (current-buffer)
(gofmt))
(setq gofmt-command gofmt-command-bak
gofmt-args gofmt-args-bak)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment