2017-08-21 20:07:07 +02:00
#+TITLE : :lang go
2017-04-27 18:02:54 -04:00
2017-05-25 20:08:50 +02:00
This module adds [[https://golang.org ][Go ]] support.
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~ )
2017-04-27 18:12:44 -04:00
+ [[../../feature/file-templates/templates/go-mode ][File templates ]]
2017-05-25 20:08:50 +02:00
+ [[https://github.com/hlissner/emacs-snippets/tree/master/go-mode ][Snippets ]]
#+begin_quote
2017-08-21 20:07:07 +02:00
I have mixed feelings about Go. It's a decent compromise between C and higher-level languages, is pleasantly straight-forward and elegant, but lacks /native/ support for luxuries I miss from other languages, like generics, optional arguments, and function overloading. You've got to learn to love ~interface{}~ .
2017-05-25 20:08:50 +02:00
2017-11-05 17:16:13 +01:00
Still, Go is a remarkably useful (and fast!) companion for a variety of small-to-medium backend web and CLI projects.
2017-05-25 20:08:50 +02:00
#+end_quote
2017-08-21 20:07:07 +02:00
* Table of Contents :TOC:
- [[#install ][Install ]]
- [[#go ][Go ]]
- [[#dependencies ][Dependencies ]]
* Install
** 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
2017-05-03 22:36:16 +02:00
#+BEGIN_SRC sh :tangle (if (doom-system-os 'macos) "yes")
2017-04-27 18:02:54 -04:00
brew install go
#+END_SRC
*** Arch Linux
2017-05-03 22:36:16 +02:00
#+BEGIN_SRC sh :dir /sudo:: :tangle (if (doom-system-os 'arch) "yes")
2017-05-04 10:40:51 +02:00
sudo pacman --needed --noconfirm -S go
2017-04-27 18:02:54 -04:00
#+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)
+ ~goimports~ (for auto-formatting code on save and fixing imports)
+ ~gorename~ (for extra refactoring commands)
2017-05-25 20:08:50 +02:00
+ ~gore~ (for the REPL)
+ ~guru~ (for code navigation & refactoring commands)
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
2017-05-25 20:08:50 +02:00
go get -u github.com/motemen/gore
2018-10-15 09:26:47 +02:00
go get -u github.com/mdempsky/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
2017-04-27 18:02:54 -04:00
#+END_SRC