If Postfix is correctly configured, it will know how to run Procmail out of the box. Just create a simple
.procmailrc file and send yourself a message. Detailed guidance e.g. at http://www.iki.fi/era/mail/procmail-debug.html but do read through to the end before you spend time on this answer; the last paragraph suggests you don't.
You don't absolutely need Procmail for this; I believe you could configure Postfix to write to your Go program directly. But unless your program is extremely failure-resistant, Procmail offers a security scaffolding which is useful as a safety net at least during development.
To have a copy of every mail message for a user account
firstname.lastname@example.org be piped as standard input to
goprogram, the account owner's
/home/you/.procmailrc only needs
# If goprogram is in a nonstandard directory,
# add it to PATH
Obviously, make sure you have permissions to execute
goprogram and that your
PATH includes the directory where it is installed. (You could obviously pipe to
/path/to/goprogram and leave the
PATH alone, but if things get nontrivial, you want to avoid littering the
.procmailrc with hard-coded paths to every binary. Like in the shell, Procmail's default
PATH lists a number of standard system-wide locations like
c flag causes Procmail to regard this as a secondary destination, so every message will also be written to the default inbox
/var/mail/you (or maybe a
Maildir in the user's home directory, these days). Once you are confident your
goprogram doesn't lose mail (test for disk full, out of memory, etc) you can take out the
c and maybe eventually run it straight out of the Postfix
master.cf and get rid of Procmail and the Unix user account
you in favor of a virtual user.
Technically, Postfix is your MTA and MSA; it knows how to use Procmail (or Maildrop, or a bunch of other alternatives) as the MDA. In order to have an MX record, you need an MTA on the host which the MX points to. A correctly configured Postfix just needs to be told which domain name(s) it should accept inbound traffic for (basically
relay_domains, but should othewise be ready to serve as the primary MX
If you are unfamiliar with a lot of this territory, you should probably avoid running your own mail server at all. E.g. Amazon SES allows you to easily run a script of yours on every incoming message without having to worry about the quite significant administrative burden and tall learning curve of stable, secure email service.