It’s a package having some constants.
package object
type Languaege int
const (
Javascript Languaege = iota
C
Cpp
Shell
)
//========================================
how can i get the value of a type Language if I know its name?
package main
func GetConstByName(name String) {
....
}
lang := GetConstByName("Shell")
I don’t think you can do it except by hand if you want
Languageto remain aconstinteger type.Here is what I would do – make Language implement Stringer which means you can print it too. You can then invert
languageMapto turn language strings intoLanguagePlayground link
This outputs