Go is Google's formerly in-house systems programming language. At least one of the Google maintainers is an Emacs user, leading to first-class support for Emacs as a Go editor.

Go works well with autocomplete, and has a lot of nice tools:

Configuring Emacs for Go

To turn Emacs into a first-class Go editor, you'll need to do a few things.

Install Go

You can install Go with package managers on most Linux distributions, but it's also pretty easy to do it yourself and closely track Go releases. Download the most recent version from the downloads page, and then untar the downloaded tarball into your /usr/local tree:

tar -C /usr/local -xzf go1.11.4.linux-amd64.tar.gz

Update Path

Update your .bashrc to include Go binaries in the PATH variable, like this:

# Include Go binaries in PATH
export PATH=${PATH}:/usr/local/go/bin # or wherever you put it

Make the Go home

Go (if you're not using modules) requires you to keep your source code in the "Go home", typically ~/go. Go ahead (no pun intended) and make this directory:

mkdir ~/go

Install tools

Install the tools you need from the Golang package repository. For my setup, I install the godoc, gofmt, godef, and gocode tools:

go get golang.org/x/tools/cmd/...
go get github.com/rogpeppe/godef
go get -u github.com/nsf/gocode

Configure Emacs

You need to define four variables for go-mode and company-go:

My full configuration looks like this:

;; Go
(require 'company-go)
(with-eval-after-load 'go-mode
  (setenv "PATH" (concat "/usr/local/go/bin" ":" "~/go/bin" ":" (getenv "PATH")))
  (defconst godoc-and-godef-command "/usr/local/go/bin/godoc")
  (defconst godef-command "~/go/bin/godef")
  (defconst gofmt-command "/usr/local/go/bin/gofmt")
  (defconst company-go-gocode-command "~/go/bin/gocode")
  (local-set-key (kbd "M-g M-d") 'godoc-at-point))
(mapc (lambda (mode)
    (add-hook 'go-mode-hook mode))
      (list 'rainbow-mode
        'hs-minor-mode
        'hideshowvis-enable
        'diff-hl-mode
        'projectile-mode
        'flycheck-mode))
(add-hook 'go-mode-hook
      (lambda ()
            (set (make-local-variable 'company-backends) '(company-go))
            (company-mode)))

References