nFPM can be used both as command line tool or as a library.
To create a sample configuration file, run:
You can then customize it and package to the formats you want:
nfpm pkg --packager deb --target /tmp/ nfpm pkg --packager rpm --target /tmp/
You can learn about it in more detail in the command line reference section.
Check out the GoDocs page, the nFPM command line implementation and GoReleaser's usage.