I am trying to write Go code that will check whether or not a string represents a valid locale. From the documentation, I've gotten to here:
import "golang.org/x/text/language"
locale := "en"
tag, err := language.Parse(locale)
if err != nil {
return errors.New("Invalid locale: " + locale)
}
I think that this should work, and it seems to work most of the time, but it doesn't always give me an error when I expect it to. For example, if I say locale := "bcd"
I don't get an error.
What am I missing here?