doomemacs/modules/lang/go/README.org

55 lines
1.8 KiB
Org Mode
Raw Normal View History

2017-05-26 02:08:50 +08:00
* :lang go
2017-05-26 02:08:50 +08:00
This module adds [[https://golang.org][Go]] support.
2017-05-26 02:08:50 +08:00
+ Code completion (~gocode~)
+ Documentation lookup (~godoc~)
+ Eldoc support (~go-eldoc~)
2017-05-26 02:08:50 +08:00
+ REPL (~gore~)
+ Syntax-checking (~flycheck~)
+ Auto-formatting on save (~gofmt~)
+ Code navigation & refactoring (~go-guru~)
+ [[../../feature/file-templates/templates/go-mode][File templates]]
2017-05-26 02:08:50 +08:00
+ [[https://github.com/hlissner/emacs-snippets/tree/master/go-mode][Snippets]]
#+begin_quote
I have mixed feelings about Go. It's a decent compromise between C and higher-level languages. It's a pleasantly straight-forward language with elegant syntax, but it lacks /native/ support for certain luxuries I miss from other languages, like generics, optional arguments, and function overloading. You've got to learn to love ~interface{}~.
2017-05-26 02:08:50 +08:00
Still, Go has been a remarkably useful (and fast!) companion for a variety of small-to-medium backend web and CLI projects.
#+end_quote
** Install
To get started with Go, you need the ~go~ tool:
*** MacOS
2017-05-04 04:36:16 +08:00
#+BEGIN_SRC sh :tangle (if (doom-system-os 'macos) "yes")
brew install go
#+END_SRC
*** Arch Linux
2017-05-04 04:36:16 +08:00
#+BEGIN_SRC sh :dir /sudo:: :tangle (if (doom-system-os 'arch) "yes")
sudo pacman --needed --noconfirm -S go
#+END_SRC
2017-05-26 02:08:50 +08:00
** Dependencies
This module requires a valid ~GOPATH~, and the following Go packages:
+ ~gocode~ (for code completion)
+ ~godoc~ (for documentation lookup)
+ ~goimports~ (for auto-formatting code on save and fixing imports)
+ ~gorename~ (for extra refactoring commands)
2017-05-26 02:08:50 +08:00
+ ~gore~ (for the REPL)
+ ~guru~ (for code navigation & refactoring commands)
#+BEGIN_SRC sh
2017-05-04 04:36:16 +08:00
export GOPATH=~/work/go
2017-05-26 02:08:50 +08:00
go get -u github.com/motemen/gore
go get -u github.com/nsf/gocode
go get -u golang.org/x/tools/cmd/godoc
go get -u golang.org/x/tools/cmd/goimports
2017-05-26 02:08:50 +08:00
go get -u golang.org/x/tools/cmd/gorename
go get -u golang.org/x/tools/cmd/guru
#+END_SRC