Next: , Up: Go-Mode Features   [Index]


A.4.1 Reading Documentation

godoc function

you can invoke the identically named Go tool from within Emacs and read package documentation in a view-mode buffer. Additional feature: You can tab complete import paths.

gofmt

automatically formats your code to the one true coding style, used by every Go developer.

In Emacs, there are two ways to use gofmt.

  1. invoke gofmt manually with the identically named function gofmt, which will patch the current buffer according to gofmt.
  2. use a before-save-hook to run gofmt every time you save a Go buffer. Enabling that hook is as easy as doing:
    (add-hook 'before-save-hook 'gofmt-before-save)
    
eldoc

https://github.com/syohex/emacs-go-eldoc provides eldoc functionality for go-mode.