package licences // A licence's key form (design 39 bus-and-switch ยง10, B6): the name every verb and tool takes and answers, written // in the characters a key of the bus takes. import "strings" // KeyFor is a licence's key: its name in lower case, each `@` written as `_at_`, and every other character // outside letters, digits, `-` and `.` written as `_`. func KeyFor(name string) string { var b strings.Builder for _, r := range strings.ToLower(name) { switch { case r == '@': b.WriteString("_at_") case r >= 'a' && r <= 'z', r >= '0' && r <= '9', r == '-', r == '.': b.WriteRune(r) default: b.WriteByte('_') } } return b.String() }