An Emacs package to align Golang struct tags that uses formattag
While gofmt
exists in go-mode which is just `go fmt` is some where pretty equivalent to formattag
,
However i find that formattag handles tags better when dealing with json and xml.
First let’s download formattag
.
Either compile it yourself or download a prebuilt binary
cd /tmp && wget https://github.com/momaek/formattag/releases/download/v0.0.9/formattag.tar.gz
gunzip -d formattag.tar.gz && tar -xf formattag.tar
sudo cp formattag-linux-amd64 /usr/local/bin/formattag
Now let’s use gofmt-tag.
In Doom Emacs packages.el
(package! gofmt-tag :recipe (:host github :repo "m1ndo/gofmt-tag"))
In Doom Emacs / Vanilla Emacs
(require 'gofmt-tag)
(add-hook 'go-mode-hook #'(lambda () (gofmt-tag-mode)))