func (n *NamespaceNamer) ToPublicName(name string) string {
	if n.shortNames {
		if parts := strings.Split(name, "."); len(parts) > 2 {
			name = strings.Join(parts[len(parts)-2:], ".")
		}
	}
	name = n.re.ReplaceAllString(name, " ")
	return strings.Replace(strings.Title(name), " ", "", -1)
}
ToPublicName implements the go-idiomatic public name as in DefaultNamer's
struct, but with additional treatment applied in order to remove possible
invalid tokens from it. Final string is then converted to camel-case.
package generator
import (
	"regexp"
	"strings"
)
const (
	invalidTokensExpr = `[._\s]+`
)
type Namer interface {
	ToPublicName(name string) string
}
type DefaultNamer struct {
}
type NamespaceNamer struct {
	shortNames bool
	re         *regexp.Regexp
}
var (
	namer Namer = &DefaultNamer{}
)
func NewNamespaceNamer(shortNames bool) *NamespaceNamer {
	return &NamespaceNamer{shortNames: shortNames, re: regexp.MustCompile(invalidTokensExpr)}
}
func SetNamer(n Namer) {
	namer = n
}
func (d *DefaultNamer) ToPublicName(name string) string {
	return ToPublicSimpleName(name)
}