#+TITLE: lang/go
#+DATE:  January 16, 2017
#+SINCE: v2.0
#+STARTUP: inlineimages

* Table of Contents :TOC:
- [[#description][Description]]
  - [[#module-flags][Module Flags]]
  - [[#plugins][Plugins]]
- [[#prerequisites][Prerequisites]]
  - [[#go][Go]]
  - [[#dependencies][Dependencies]]
- [[#features][Features]]
- [[#configuration][Configuration]]
- [[#troubleshooting][Troubleshooting]]

* Description
This module adds [[https://golang.org][Go]] support, with optional (but recommended) LSP support via
[[https://github.com/golang/tools/blob/master/gopls/README.md][gopls]].

+ Code completion (~gocode~)
+ Documentation lookup (~godoc~)
+ Eldoc support (~go-eldoc~)
+ REPL (~gore~)
+ Syntax-checking (~flycheck~)
+ Auto-formatting on save (~gofmt~) (requires =:editor (format +onsave)=)
+ Code navigation & refactoring (~go-guru~)
+ [[../../editor/file-templates/templates/go-mode][File templates]]
+ [[https://github.com/hlissner/doom-snippets/tree/master/go-mode][Snippets]]
+ Generate testing code (~go-gen-test~)
+ Code checking (~flycheck-golangci-lint~)

** Module Flags
+ =+lsp= Enables integration for the gopls LSP server. It is highly recommended
  you use this, as the non-LSP experience is deprecated (and poor).

** Plugins
+ [[https://github.com/dominikh/go-mode.el][go-mode]]
+ [[https://github.com/syohex/emacs-go-eldoc][go-eldoc]]
+ [[https://github.com/dominikh/go-mode.el][go-guru]]
+ [[https://github.com/manute/gorepl-mode][gorepl-mode]]
+ [[https://github.com/brantou/emacs-go-tag][go-tag]]
+ [[https://github.com/mdempsky/gocode][company-go]]* =DEPRECATED=
+ [[https://github.com/s-kostyaev/go-gen-test][go-gen-test]]
+ [[https://github.com/weijiangan/flycheck-golangci-lint][flycheck-golangci-lint]] (if =:checkers syntax= is enabled)

* Prerequisites
** Go
To get started with Go, you need the ~go~ tool:

*** MacOS
#+BEGIN_SRC bash
brew install go
#+END_SRC

*** Arch Linux
#+BEGIN_SRC bash
sudo pacman -S go
#+END_SRC

*** openSUSE
#+BEGIN_SRC sh :dir /sudo::
sudo zypper install go
#+END_SRC

** Dependencies
This module requires a valid ~GOPATH~, and the following Go packages:

+ ~gocode~ (for code completion & eldoc support)
+ ~godoc~ (for documentation lookup)
+ ~gorename~ (for extra refactoring commands)
+ ~gore~ (for the REPL)
+ ~guru~ (for code navigation & refactoring commands)
+ ~goimports~ (optional: for auto-formatting code on save & fixing imports)
+ ~gotests~ (for generate test code)
+ ~gomodifytags~ (for manipulating tags)

#+BEGIN_SRC sh
export GOPATH=~/work/go

go get -u github.com/x-motemen/gore/cmd/gore
go get -u github.com/stamblerre/gocode
go get -u golang.org/x/tools/cmd/godoc
go get -u golang.org/x/tools/cmd/goimports
go get -u golang.org/x/tools/cmd/gorename
go get -u golang.org/x/tools/cmd/guru
go get -u github.com/cweill/gotests/...
go get -u github.com/fatih/gomodifytags
#+END_SRC

+ ~golangci-lint~ (optional: for flycheck to integrate golangci-lint results)
  it is recommended to *not* use ~go get~ to install this one, check the
  [[https://github.com/golangci/golangci-lint#binary-release][documentation]].

* TODO Features

* TODO Configuration

* TODO Troubleshooting
