From e9d4837d4225a7c98a8348ecbcb054633a406bd5 Mon Sep 17 00:00:00 2001 From: xpetit <32063953+xpetit@users.noreply.github.com> Date: Thu, 17 Jun 2021 22:38:29 +0200 Subject: [PATCH] Fix bug & simplify --- .../ubuntu/system/usr/local/src/format/main.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/sh/debian/ubuntu/system/usr/local/src/format/main.go b/sh/debian/ubuntu/system/usr/local/src/format/main.go index 114f5f32c..c14067386 100644 --- a/sh/debian/ubuntu/system/usr/local/src/format/main.go +++ b/sh/debian/ubuntu/system/usr/local/src/format/main.go @@ -159,27 +159,21 @@ func main() { renderTable(table) // Select the USB flash drive to format - if len(devices) == 1 { - fmt.Println(`Press ENTER to format the disk (or "exit")`) - } else { - fmt.Println(`Enter the number of the disk you want to format (or "exit"):`) - } + fmt.Println(`Enter the number of the disk you want to format (or "exit"):`) var choice string fmt.Scanln(&choice) if strings.ToLower(choice) == "exit" { return } var nb int - if choice != "" { - nb, err := strconv.Atoi(choice) - if err != nil || nb < 0 || nb >= len(devices) { - fatalln("Wrong disk number:", choice) - } + nb, err := strconv.Atoi(choice) + if err != nil || nb < 0 || nb >= len(devices) { + fatalln("Wrong disk number:", choice) } device := devices[nb] // Get a list of the USB flash drive mount points - b, err := os.ReadFile("/proc/mounts") + b, err = os.ReadFile("/proc/mounts") expect(nil, err, "list the mount points") lines := strings.Split(string(b), "\n") var mountPoints []string