From 292076d750d38e35c02e4b5d47aa2049d75d6b5a Mon Sep 17 00:00:00 2001 From: Carlos Nihelton Date: Tue, 4 Jun 2024 10:04:02 -0300 Subject: [PATCH] Checks for fmt.Scanf errors That pleases the new linter warning. --- mocks/restserver/application.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mocks/restserver/application.go b/mocks/restserver/application.go index 85e134ef9..3675f82be 100644 --- a/mocks/restserver/application.go +++ b/mocks/restserver/application.go @@ -178,8 +178,12 @@ The outfile, if provided, will contain the address.`, app.Description), slog.Info(fmt.Sprintf("Serving on address %s", addr)) // Wait loop - for scanned := ""; scanned != "exit"; fmt.Scanf("%s\n", &scanned) { + for scanned := ""; scanned != "exit"; { fmt.Println("Write 'exit' to stop serving") + if _, err := fmt.Scanf("%s\n", &scanned); err != nil { + slog.Error(fmt.Sprintf("Could not scan input: %v", err)) + os.Exit(1) + } } }, }