Skip to content

Latest commit

 

History

History
28 lines (27 loc) · 1.79 KB

GolangInDoom.org

File metadata and controls

28 lines (27 loc) · 1.79 KB

Golang in Doom Emacs

Config

  • Don’t forget to uncomment go in init.el
    • Enable lsp under :tools and change go to (go +lsp) if you’re planning to use a Language Protocol Server using lsp-mode.
    • Enable syntax under :checkers if you’re planning to use golangci-lint as your linter via flycheck. I recommend that you set golangci-lint as the next flychecker after LSP.
    • Enable (web +html) under :lang, this will install web-mode. To use it for your Go templates, first enable web mode web-mode, then do M-x web-mode-set-engine and choose go.
    • Enable (format +onsave) under :editor to run gofmt on each save

First Steps

  • Run doom doctor and look inside the :lang go section to see what executables you lack and install them.

Basics

  • First see LSP part of the main file and figure out how they are used in go-mode. For example:
    • Running go run file.go corresponds to SPC c e
    • Running go fmt file.go corresponds to SPC c f
  • C-c C-g or M-x gorepl-run to open a go repl on top of gore.
  • C-c C-e or M-x gorepl-eval-region to evaluate the selected region.

Tests & Benchmarks

  • SPC m t a to run all existing tests
  • SPC m t b a to run all existing benchmarks
  • SPC m t G to write tests for all functions using gotests
  • SPC m t g to write tests for selected functions using gotests

Go Playground

  • M-x (or equivalently) SPC : with:
    • go-play-buffer to send selected buffer to the Playground
    • go-play-region to send selected region to the Playground
    • go-download-play to download from the Playground

Sources