Use lsp-mode. gopls is built in now as a client, so no special config is necessary. You first must install
gopls and put it somewhere in your
PATH. Here is an example (assuming you are using use-package) to get you started:
(use-package lsp-mode :commands (lsp lsp-deferred)) (add-hook 'go-mode-hook #'lsp-deferred) ;; optional - provides fancier overlays (use-package lsp-ui :commands lsp-ui-mode) ;; if you use company-mode for completion (otherwise, complete-at-point works out of the box): (use-package company-lsp :commands company-lsp)
M-x getenv <RET> PATH <RET>to see if your PATH is set in Emacs. If not, you can try starting Emacs from your terminal, using this package, or moving your shell config from .bashrc into .bashenv (or .zshenv).
company-lspare up-to-date, and make sure
lsp-gois not installed.
To troubleshoot, look in the
*lsp-log* buffer for errors.