Skip to content

Instantly share code, notes, and snippets.

@klizhentas
Created November 17, 2015 02:12
Show Gist options
  • Save klizhentas/fb01554b3ab5ae8bc401 to your computer and use it in GitHub Desktop.
Save klizhentas/fb01554b3ab5ae8bc401 to your computer and use it in GitHub Desktop.
go plugins for emacs
; ==================
; Go plugins
; ==================
(setenv "GOPATH" "/home/alex/go")
(setenv "GOROOT" "/opt/go")
(setenv "PATH" (concat (getenv "PATH") ":/home/alex/go/bin" ":/opt/go/bin" ":~/.emacs.d/goflymake"))
(setq exec-path (append exec-path (list (expand-file-name "~/.emacs.d/goflymake"))))
(require 'go-mode)
(require 'go-flymake)
(defun my-go-mode-hook ()
; Use goimports instead of go-fmt
(setq gofmt-command "gofmt")
; Call Gofmt before saving
(add-hook 'before-save-hook 'gofmt-before-save)
; Customize compile command to run go build
(if (not (string-match "go" compile-command))
(set (make-local-variable 'compile-command)
"go build -v && go test -v && go vet"))
; Godef jump key binding
(local-set-key (kbd "C-.") 'godef-jump))
(add-hook 'go-mode-hook 'my-go-mode-hook)
(global-set-key (kbd "C-,") 'pop-tag-mark)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment