2019-01-03 01:53:13 -05:00
|
|
|
#+TITLE: lang/go
|
|
|
|
#+DATE: January 16, 2017
|
|
|
|
#+SINCE: v2.0
|
|
|
|
#+STARTUP: inlineimages
|
2017-04-27 18:02:54 -04:00
|
|
|
|
2019-01-03 01:53:13 -05:00
|
|
|
* Table of Contents :TOC:
|
2019-08-27 10:50:37 +02:00
|
|
|
- [[#description][Description]]
|
|
|
|
- [[#module-flags][Module Flags]]
|
|
|
|
- [[#plugins][Plugins]]
|
|
|
|
- [[#prerequisites][Prerequisites]]
|
|
|
|
- [[#go][Go]]
|
|
|
|
- [[#dependencies][Dependencies]]
|
|
|
|
- [[#features][Features]]
|
|
|
|
- [[#configuration][Configuration]]
|
|
|
|
- [[#troubleshooting][Troubleshooting]]
|
2019-01-03 01:53:13 -05:00
|
|
|
|
|
|
|
* Description
|
2020-04-17 22:22:10 -04:00
|
|
|
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]].
|
2017-04-27 18:02:54 -04:00
|
|
|
|
2017-05-25 20:08:50 +02:00
|
|
|
+ Code completion (~gocode~)
|
2017-05-26 02:13:47 +02:00
|
|
|
+ Documentation lookup (~godoc~)
|
|
|
|
+ Eldoc support (~go-eldoc~)
|
2017-05-25 20:08:50 +02:00
|
|
|
+ REPL (~gore~)
|
|
|
|
+ Syntax-checking (~flycheck~)
|
|
|
|
+ Auto-formatting on save (~gofmt~)
|
|
|
|
+ Code navigation & refactoring (~go-guru~)
|
2019-04-21 19:59:44 -04:00
|
|
|
+ [[../../editor/file-templates/templates/go-mode][File templates]]
|
2019-07-14 14:43:45 +02:00
|
|
|
+ [[https://github.com/hlissner/doom-snippets/tree/master/go-mode][Snippets]]
|
2019-10-23 01:06:46 +09:00
|
|
|
+ Generate testing code (~go-gen-test~)
|
2019-10-30 09:36:05 +01:00
|
|
|
+ Code checking (~flycheck-golangci-lint~)
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:53:13 -05:00
|
|
|
** Module Flags
|
2020-04-17 22:22:10 -04:00
|
|
|
+ =+lsp= Enables integration for the gopls LSP server. It is highly recommended
|
|
|
|
you use this, as the non-LSP experience is deprecated (and poor).
|
2017-05-25 20:08:50 +02:00
|
|
|
|
2019-01-03 01:53:13 -05:00
|
|
|
** 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]]
|
2019-11-06 14:22:24 +01:00
|
|
|
+ [[https://github.com/brantou/emacs-go-tag][go-tag]]
|
2020-04-17 22:22:10 -04:00
|
|
|
+ [[https://github.com/mdempsky/gocode][company-go]]* =DEPRECATED=
|
2019-10-23 01:06:46 +09:00
|
|
|
+ [[https://github.com/s-kostyaev/go-gen-test][go-gen-test]]
|
2020-01-14 03:04:26 -05:00
|
|
|
+ [[https://github.com/weijiangan/flycheck-golangci-lint][flycheck-golangci-lint]] (if =:checkers syntax= is enabled)
|
2017-08-21 20:07:07 +02:00
|
|
|
|
2019-01-03 01:53:13 -05:00
|
|
|
* Prerequisites
|
2017-08-21 20:07:07 +02:00
|
|
|
** Go
|
2017-05-25 20:08:50 +02:00
|
|
|
To get started with Go, you need the ~go~ tool:
|
2017-04-27 18:02:54 -04:00
|
|
|
|
|
|
|
*** MacOS
|
2019-01-03 01:53:13 -05:00
|
|
|
#+BEGIN_SRC bash
|
2017-04-27 18:02:54 -04:00
|
|
|
brew install go
|
|
|
|
#+END_SRC
|
|
|
|
|
|
|
|
*** Arch Linux
|
2019-01-03 01:53:13 -05:00
|
|
|
#+BEGIN_SRC bash
|
|
|
|
sudo pacman -S go
|
2017-04-27 18:02:54 -04:00
|
|
|
#+END_SRC
|
|
|
|
|
2019-08-27 10:50:37 +02:00
|
|
|
*** openSUSE
|
|
|
|
#+BEGIN_SRC sh :dir /sudo::
|
|
|
|
sudo zypper install go
|
|
|
|
#+END_SRC
|
|
|
|
|
2017-05-25 20:08:50 +02:00
|
|
|
** Dependencies
|
|
|
|
This module requires a valid ~GOPATH~, and the following Go packages:
|
|
|
|
|
2017-05-26 11:44:06 +02:00
|
|
|
+ ~gocode~ (for code completion & eldoc support)
|
2017-05-26 02:13:47 +02:00
|
|
|
+ ~godoc~ (for documentation lookup)
|
|
|
|
+ ~gorename~ (for extra refactoring commands)
|
2017-05-25 20:08:50 +02:00
|
|
|
+ ~gore~ (for the REPL)
|
|
|
|
+ ~guru~ (for code navigation & refactoring commands)
|
2019-01-03 01:53:13 -05:00
|
|
|
+ ~goimports~ (optional: for auto-formatting code on save & fixing imports)
|
2019-10-23 01:06:46 +09:00
|
|
|
+ ~gotests~ (for generate test code)
|
2019-11-06 14:22:24 +01:00
|
|
|
+ ~gomodifytags~ (for manipulating tags)
|
2017-04-27 18:02:54 -04:00
|
|
|
|
|
|
|
#+BEGIN_SRC sh
|
2017-05-03 22:36:16 +02:00
|
|
|
export GOPATH=~/work/go
|
2017-04-27 18:02:54 -04:00
|
|
|
|
2019-04-19 18:34:25 -05:00
|
|
|
go get -u github.com/motemen/gore/cmd/gore
|
2020-02-24 11:17:22 -05:00
|
|
|
go get -u github.com/stamblerre/gocode
|
2017-05-26 02:13:47 +02:00
|
|
|
go get -u golang.org/x/tools/cmd/godoc
|
|
|
|
go get -u golang.org/x/tools/cmd/goimports
|
2017-05-25 20:08:50 +02:00
|
|
|
go get -u golang.org/x/tools/cmd/gorename
|
2017-05-26 02:13:47 +02:00
|
|
|
go get -u golang.org/x/tools/cmd/guru
|
2019-10-23 01:06:46 +09:00
|
|
|
go get -u github.com/cweill/gotests/...
|
2019-11-06 14:22:24 +01:00
|
|
|
go get -u github.com/fatih/gomodifytags
|
2017-04-27 18:02:54 -04:00
|
|
|
#+END_SRC
|
|
|
|
|
2019-10-30 09:36:05 +01:00
|
|
|
+ ~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]].
|
|
|
|
|
2019-01-03 01:53:13 -05:00
|
|
|
* TODO Features
|
|
|
|
|
|
|
|
* TODO Configuration
|
|
|
|
|
|
|
|
* TODO Troubleshooting
|