New: `GenSignature()`
This PR introduces a new function with test:
// GenSignature reads message from r and return signature (without `DKIM-Signature:` header key).
GenSignature(r io.Reader, options *SignOptions) (signature string, err error)
Why we need this new function?
While developing a milter program with https://github.com/emersion/go-milter or its fork, we need to insert the DKIM-Signature: header, in this case we need go-msgauth library to return the generated dkim signature (header value) instead of a new email message with this header. This new function simplifies such task and saves some memory.
How is this different from NewSigner followed by Signer.Signature?
Hi @emersion
Sign() always generates a new (full) message with dkim header (w io.Writer), we just need the generated signature, not a new message. This GenSignature() avoids generating a new message, hence it saves memory. This is useful if we're developing a dkim signing plugin for a milter program.
// Sign signs a message. It reads it from r and writes the signed version to w.
func Sign(w io.Writer, r io.Reader, options *SignOptions) error {
https://github.com/emersion/go-msgauth/blob/master/dkim/sign.go#L309
My suggestion was not to use Sign, but NewSigner + Signer.Signature.
OK. Thanks for helping. :)