Is it possible to run formatter before saving?

Stepan Bujnak <[email protected]> Fri, 30 Apr 2021 00:00:29 +0200
Newsgroups gmane.editors.nano.general
Message-ID <CA+0ge-QEGze1fNc0QqAn847kCnbTH1_gO+b63x=o-xV4+i1LFw@mail.gmail.com>
I'm writing a lot of Go code. When editing a Go file in nano, I would like
to run `goimports -w` which automatically formats the code right before
saving. I can do that by binding it to a key combination, but I'm
interested whether it would be possible to run the formatter automatically
after pressing ^S or ^X and before saving the file. Thank you.