You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
589 B

package mime
import (
"bytes"
"strings"
"unicode"
"github.com/achiku/varfmt"
)
func VarName(prefix, name string) string {
rules := map[string]string{
"+": "_plus",
"-": "_dash_",
"/": "_",
".": "_dot_",
}
for old, new := range rules {
name = strings.ReplaceAll(name, old, new)
}
if unicode.IsUpper(rune(name[0])) {
name = " " + name
}
return varfmt.PublicVarName(prefix + "_" + name)
}
func Value(prefix string, val []string) string {
var out bytes.Buffer
for _, name := range val {
out.WriteString(VarName(prefix, name) + ",")
}
return out.String()
}