Beispiel #1
0
func printLangs() {
	langs, err := env.SupportedLangs()

	if err != nil {
		fmt.Fprintf(os.Stderr, "%v\n", err)
		return
	}

	for _, lang := range langs {
		fmt.Printf("%s\n", lang)
	}
}
Beispiel #2
0
func validateLang(lang string) {
	langs, err := env.SupportedLangs()

	if err != nil {
		fmt.Fprintf(os.Stderr, "%v\n", err)
		os.Exit(2)
	}

	langsSlice := sort.StringSlice(langs)
	langsSlice.Sort()

	if langsSlice.Search(lang) == langsSlice.Len() {
		fmt.Fprintf(os.Stderr, "'%s' is not a valid language\n", lang)
		fmt.Fprintf(os.Stderr, "Use -languages to see valid options\n")
		os.Exit(2)
	}
}