Skip to content

Commit

Permalink
Checks for fmt.Scanf errors
Browse files Browse the repository at this point in the history
That pleases the new linter warning.
  • Loading branch information
CarlosNihelton committed Jun 4, 2024
1 parent acc9ec5 commit 292076d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mocks/restserver/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
},
}
Expand Down

0 comments on commit 292076d

Please sign in to comment.