Skip to content

Instantly share code, notes, and snippets.

@chenyukang
Created June 22, 2014 14:38
Show Gist options
  • Save chenyukang/9bbf1ef3be82fad7484f to your computer and use it in GitHub Desktop.
Save chenyukang/9bbf1ef3be82fad7484f to your computer and use it in GitHub Desktop.
Emacs for Go
;; golang
(add-to-list 'load-path "~/.emacs.d/go-mode")
(require 'go-mode)
(require 'go-mode-load)
(require 'go-autocomplete)
(require 'auto-complete-config)
(setq gofmt-command "goimports")
(load-file "~/.emacs.d/go-autocomplete.el")
(add-hook 'before-save-hook 'gofmt-before-save)
(add-hook 'go-mode-hook (lambda ()
(local-set-key (kbd "C-c C-r") 'go-remove-unused-imports)))
(add-hook 'go-mode-hook (lambda ()
(local-set-key (kbd "C-c C-r") 'go-remove-unused-imports)))
(defun run-cover ()
"Run go coverage in tmp dir"
(interactive)
(let ((cmd (format "gocover %s" (buffer-file-name))))
(shell-command cmd)))
(global-set-key (kbd "C-x g") 'run-cover)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment