Пример #1
0
func selectTranslation(termData []WRData) int64 {
	scan := scanner.Scanner{}
	scan.Init(os.Stdin)
	fmt.Print("Select one of the translations (e.g., 1): ")
	scan.Scan()

	if !scan.IsValid() {
		return -1
	}

	index, err := strconv.ParseInt(scan.TokenText(), 10, 64)
	if err != nil || index > int64(len(termData))-1 {
		return -1
	}

	return index
}