(use-package go-mode :ensure t :after (exec-path-from-shell flycheck flyspell company company-go hydra) :hook ((go-mode . fcuny/go-mode-setup) (go-mode . company-mode)) :bind (("C-c a ?" . godoc-at-point) ("C-c a ." . godef-jump) ("C-c a a" . go-import-add)) :custom (godoc-use-completing-read t) (gofmt-command "goimports") ;; see https://github.com/dominikh/go-mode.el/issues/262 (godoc-at-point-function 'godoc-gogetdoc) :init (defun fcuny/go-mode-setup () (setq tab-width 4) (add-hook 'before-save-hook 'gofmt-before-save)) :config (when (memq window-system '(mac ns)) (exec-path-from-shell-copy-env "GOPATH")) (defhydra go-hydra (:color teal :columns 3) "Go" ("r" go-guru-referrers "referrers") ("i" go-guru-implements "implements") ("d" go-guru-definition "definition") ("D" go-guru-describe "describe") ("t" go-test-current-test "run this test") ("f" go-test-current-file "run tests for this file")) (define-key go-mode-map (kbd "C-c g") 'go-hydra/body)) (use-package go-guru :ensure t :after go-mode :commands (go-guru-describe go-guru-freevars go-guru-implements go-guru-peers go-guru-referrers go-guru-definition go-guru-pointsto go-guru-callstack go-guru-whicherrs go-guru-callers go-guru-callees go-guru-expand-region) :config (unless (executable-find "guru") (warn "go-mode: couldn't find guru, refactoring commands won't work")) (add-hook 'go-mode-hook #'go-guru-hl-identifier-mode)) (use-package go-eldoc :ensure t :after go-mode :config (add-hook 'go-mode-hook 'go-eldoc-setup)) (use-package godoctor :ensure t :after go-mode) (use-package gotest :ensure t :after go-mode) (provide 'fcuny-go)