Skip to content

Commit

Permalink
input: Add (Key).String()
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed Apr 13, 2018
1 parent 61d4df0 commit 95c4ce0
Show file tree
Hide file tree
Showing 2 changed files with 212 additions and 0 deletions.
11 changes: 11 additions & 0 deletions genkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,17 @@ const (
{{end}} KeyMax Key = Key{{.LastKeyName}}
)
// String returns a string representing the key.
//
// If k is an undefined key, String returns an empty string.
func (k Key) String() string {
switch k {
{{range $name := .KeyNames}}case Key{{$name}}:
return {{$name | printf "%q"}}
{{end}}}
return ""
}
func keyNameToKey(name string) (Key, bool) {
switch strings.ToLower(name) {
{{range $name := .KeyNames}}case {{$name | printf "%q" | ToLower}}:
Expand Down
201 changes: 201 additions & 0 deletions keys.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 95c4ce0

Please sign in to comment.