func addMdns(controller *spotcontrol.SpircController, reader *bufio.Reader) { devices, err := controller.ListMdnsDevices() if err != nil { fmt.Println("Mdns devices can only be found when micro-controller is started \n" + "in discovery mode. Restart without a username and password and with a --blobPath \n" + "argument (path where discovery blob will be saved) to start micro-controller in \n" + "disocvery mode \n") return } if len(devices) == 0 { fmt.Println("no devices found") return } fmt.Println("\n choose a device:") for i, d := range devices { fmt.Printf("%v) [mdns]%v %v \n", i, d.Name, d.Url) } var url string for { fmt.Print("Enter device number: ") text, _ := reader.ReadString('\n') i, err := strconv.Atoi(strings.TrimSpace(text)) if err == nil && i < len(devices) && i >= 0 { url = devices[i].Url break } fmt.Println("invalid device number") } controller.ConnectToDevice(url) }