如何在Golang中获取带引号的可打印字符串

How to get a quoted printable string created according to » RFC2045, section 6.7. in golang

PHP equivalent is "quoted_printable_encode ( string $str )"

Use the standard quotedprintable package to encode the string:

...

import (
    "bytes"
    "mime/quotedprintable"
    "github.com/pkg/errors"
)

...

func toQuotedPrintable(s string) (string, error) {
    var ac bytes.Buffer
    w := quotedprintable.NewWriter(&ac)
    _, err := w.Write([]byte(s))
    if err != nil {
        return "", errors.Wrap(err, "write")
    }
    err = w.Close()
    if err != nil {
        return "", errors.Wrap(err, "close")
    }
    return ac.String(), nil
}