> For the complete documentation index, see [llms.txt](https://www.devops.buzz/public/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.devops.buzz/public/emacs/cheat-sheet.md).

# Cheat sheet

## Melpa

{% code title="\~/.emacs" %}

```
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired.  See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
```

{% endcode %}

Note that you'll need to run `M-x package-refresh-contents` or `M-x package-list-packages` to ensure that Emacs has fetched the MELPA package list before you can install packages with `M-x package-install` or similar.

### References

<https://melpa.org/#/getting-started>

## Golang

### Install go-mode.

```
M-x package-install go-mode
```

### Indenting and autoformat

{% code title="\~/.emacs" %}

```
(add-hook 'go-mode-hook
          (lambda ()
            (add-hook 'before-save-hook 'gofmt-before-save)
            (setq tab-width 4)
            (setq indent-tabs-mode 1)))
```

{% endcode %}
