2022-03-28 15:03:21 +02:00
|
|
|
#+title: :lang go
|
|
|
|
#+subtitle: The hipster dialect
|
|
|
|
#+created: June 15, 2015
|
|
|
|
#+since: 0.7
|
2021-10-16 01:28:32 +02:00
|
|
|
|
|
|
|
* Description :unfold:
|
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
|
|
|
|
2021-10-16 01:28:32 +02:00
|
|
|
- Code completion (~gocode~)
|
|
|
|
- Documentation lookup (~godoc~)
|
|
|
|
- Eldoc support (~go-eldoc~)
|
|
|
|
- REPL (~gore~)
|
|
|
|
- Syntax-checking (~flycheck~)
|
2022-09-26 02:19:42 +08:00
|
|
|
- Auto-formatting on save (~gofmt~) (requires [[doom-module::editor format +onsave]])
|
2021-10-16 01:28:32 +02:00
|
|
|
- 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~)
|
|
|
|
|
|
|
|
** Maintainers
|
|
|
|
*This module needs a maintainer.* [[doom-contrib-maintainer:][Become a maintainer?]]
|
|
|
|
|
|
|
|
** Module flags
|
|
|
|
- +lsp ::
|
2022-09-26 02:19:42 +08:00
|
|
|
Enable LSP support for ~go-mode~. Requires [[doom-module::tools lsp]] and a langserver
|
2021-10-16 01:28:32 +02:00
|
|
|
(supports gopls). Highly recommended, as the non-LSP experience is deprecated
|
|
|
|
(and poor).
|
2022-04-09 18:38:04 +03:00
|
|
|
- +tree-sitter ::
|
|
|
|
Leverages tree-sitter for better syntax highlighting and structural text
|
2022-09-26 02:19:42 +08:00
|
|
|
editing. Requires [[doom-module::tools tree-sitter]].
|
2021-10-16 01:28:32 +02:00
|
|
|
|
|
|
|
** Packages
|
2022-09-26 02:19:42 +08:00
|
|
|
- [[doom-package:company-go]] if [[doom-module::completion company]] (DEPRECATED)
|
|
|
|
- [[doom-package:flycheck-golangci-lint]] if [[doom-module::checkers syntax]]
|
|
|
|
- [[doom-package:go-eldoc]]
|
|
|
|
- [[doom-package:go-gen-test]]
|
|
|
|
- [[doom-package:go-guru]]
|
|
|
|
- [[doom-package:go-mode]]
|
|
|
|
- [[doom-package:gorepl-mode]]
|
|
|
|
- [[doom-package:go-tag]]
|
2021-10-16 01:28:32 +02:00
|
|
|
|
|
|
|
** Hacks
|
|
|
|
/No hacks documented for this module./
|
|
|
|
|
|
|
|
** TODO Changelog
|
|
|
|
# This section will be machine generated. Don't edit it by hand.
|
|
|
|
/This module does not have a changelog yet./
|
|
|
|
|
|
|
|
* Installation
|
|
|
|
[[id:01cffea4-3329-45e2-a892-95a384ab2338][Enable this module in your ~doom!~ block.]]
|
|
|
|
|
|
|
|
This module requires Go, a valid =$GOPATH=, and a number of go packages, listed
|
|
|
|
below.
|
2017-04-27 18:02:54 -04:00
|
|
|
|
2021-10-16 01:28:32 +02:00
|
|
|
** Go
|
|
|
|
- macOS: ~$ brew install go~
|
|
|
|
- Arch Linux: ~$ pacman -S go~
|
|
|
|
- openSUSE: ~$ zypper install go~
|
2019-08-27 10:50:37 +02:00
|
|
|
|
2017-05-25 20:08:50 +02:00
|
|
|
** Dependencies
|
2021-10-16 01:28:32 +02:00
|
|
|
- ~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
|
2017-05-03 22:36:16 +02:00
|
|
|
export GOPATH=~/work/go
|
2017-04-27 18:02:54 -04:00
|
|
|
|
2021-10-18 01:37:03 +02:00
|
|
|
go install github.com/x-motemen/gore/cmd/gore@latest
|
|
|
|
go install github.com/stamblerre/gocode@latest
|
|
|
|
go install golang.org/x/tools/cmd/godoc@latest
|
|
|
|
go install golang.org/x/tools/cmd/goimports@latest
|
|
|
|
go install golang.org/x/tools/cmd/gorename@latest
|
|
|
|
go install golang.org/x/tools/cmd/guru@latest
|
|
|
|
go install github.com/cweill/gotests/gotests@latest
|
|
|
|
go install github.com/fatih/gomodifytags@latest
|
2021-10-16 01:28:32 +02:00
|
|
|
#+end_src
|
2017-04-27 18:02:54 -04:00
|
|
|
|
2021-10-16 01:28:32 +02: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
|
2019-10-30 09:36:05 +01:00
|
|
|
[[https://github.com/golangci/golangci-lint#binary-release][documentation]].
|
|
|
|
|
2021-10-16 01:28:32 +02:00
|
|
|
* TODO Usage
|
|
|
|
#+begin_quote
|
|
|
|
🔨 This module has no usage documentation yet. [[doom-contrib-module:][Write some?]]
|
|
|
|
#+end_quote
|
2019-01-03 01:53:13 -05:00
|
|
|
|
2023-02-23 00:52:41 -05:00
|
|
|
** Keybinds
|
|
|
|
| Keys | Description |
|
|
|
|
|---------------------+-------------------------------------------------------|
|
|
|
|
| [[kbd:][<localleader> a]] | Add field tags to a struct |
|
|
|
|
| [[kbd:][<localleader> d]] | Remove field tags from a struct |
|
|
|
|
| [[kbd:][<localleader> e]] | Evaluate buffer or selection in the Go playground |
|
|
|
|
| [[kbd:][<localleader> i]] | Go to imports |
|
|
|
|
| [[kbd:][<localleader> b c]] | run ~$ go clean~ |
|
|
|
|
| [[kbd:][<localleader> b b]] | run ~$ go build~ |
|
|
|
|
| [[kbd:][<localleader> b r]] | run ~$ go run .~ |
|
|
|
|
| [[kbd:][<localleader> h .]] | lookup symbol at point in godoc |
|
|
|
|
| [[kbd:][<localleader> h d]] | describe symbol at point |
|
|
|
|
| [[kbd:][<localleader> h v]] | list free variables |
|
|
|
|
| [[kbd:][<localleader> h i]] | list implements relations for package types |
|
|
|
|
| [[kbd:][<localleader> h p]] | list peers for channel |
|
|
|
|
| [[kbd:][<localleader> h P]] | "what does this point to" |
|
|
|
|
| [[kbd:][<localleader> h r]] | list references to object |
|
|
|
|
| [[kbd:][<localleader> h e]] | which errors |
|
|
|
|
| [[kbd:][<localleader> h w]] | what query |
|
|
|
|
| [[kbd:][<localleader> h c]] | show callers of function at point |
|
|
|
|
| [[kbd:][<localleader> h C]] | show callees of function at point |
|
|
|
|
| [[kbd:][<localleader> t t]] | rerun last test |
|
|
|
|
| [[kbd:][<localleader> t a]] | run all tests in project |
|
|
|
|
| [[kbd:][<localleader> t f]] | run all tests in current file |
|
|
|
|
| [[kbd:][<localleader> t s]] | run single test at point |
|
|
|
|
| [[kbd:][<localleader> t g]] | Generate tests for all exported or selected functions |
|
|
|
|
| [[kbd:][<localleader> t G]] | Generate tests for all functions |
|
|
|
|
| [[kbd:][<localleader> t e]] | Generate tests for all exported functions |
|
|
|
|
| [[kbd:][<localleader> t b s]] | go test.bench single |
|
|
|
|
| [[kbd:][<localleader> t b a]] | go test.bench all |
|
|
|
|
| [[kbd:][<localleader> r i a]] | search imports to add |
|
|
|
|
| [[kbd:][<localleader> r i r]] | reimove unused imports |
|
|
|
|
|
2019-01-03 01:53:13 -05:00
|
|
|
* TODO Configuration
|
2021-10-16 01:28:32 +02:00
|
|
|
#+begin_quote
|
|
|
|
🔨 This module has no configuration documentation yet. [[doom-contrib-module:][Write some?]]
|
|
|
|
#+end_quote
|
|
|
|
|
|
|
|
* Troubleshooting
|
|
|
|
/There are no known problems with this module./ [[doom-report:][Report one?]]
|
|
|
|
|
|
|
|
* Frequently asked questions
|
|
|
|
/This module has no FAQs yet./ [[doom-suggest-faq:][Ask one?]]
|
2019-01-03 01:53:13 -05:00
|
|
|
|
2021-10-16 01:28:32 +02:00
|
|
|
* TODO Appendix
|
|
|
|
#+begin_quote
|
|
|
|
🔨 This module has no appendix yet. [[doom-contrib-module:][Write one?]]
|
|
|
|
#+end_quote
|