cli/command: minor cleanups: use Println, suppress errors

- use Println to print newline instead of custom format
- suppress some errors to make my IDE and linters happier

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-02-01 23:16:01 +01:00
parent cd6d902dff
commit dc5a4501a4
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 6 additions and 6 deletions

View File

@ -114,7 +114,7 @@ func (cli *DockerCli) CurrentVersion() string {
// Client returns the APIClient
func (cli *DockerCli) Client() client.APIClient {
if err := cli.initialize(); err != nil {
_, _ = fmt.Fprintf(cli.Err(), "Failed to initialize: %s\n", err)
_, _ = fmt.Fprintln(cli.Err(), "Failed to initialize:", err)
os.Exit(1)
}
return cli.client
@ -475,7 +475,7 @@ func (cli *DockerCli) DockerEndpoint() docker.Endpoint {
if err := cli.initialize(); err != nil {
// Note that we're not terminating here, as this function may be used
// in cases where we're able to continue.
_, _ = fmt.Fprintf(cli.Err(), "%v\n", cli.initErr)
_, _ = fmt.Fprintln(cli.Err(), cli.initErr)
}
return cli.dockerEndpoint
}

View File

@ -177,19 +177,19 @@ func TestPromptForConfirmation(t *testing.T) {
return nil
}, promptResult{false, command.ErrPromptTerminated}},
{"no", func() error {
_, err := fmt.Fprint(promptWriter, "n\n")
_, err := fmt.Fprintln(promptWriter, "n")
return err
}, promptResult{false, nil}},
{"yes", func() error {
_, err := fmt.Fprint(promptWriter, "y\n")
_, err := fmt.Fprintln(promptWriter, "y")
return err
}, promptResult{true, nil}},
{"any", func() error {
_, err := fmt.Fprint(promptWriter, "a\n")
_, err := fmt.Fprintln(promptWriter, "a")
return err
}, promptResult{false, nil}},
{"with space", func() error {
_, err := fmt.Fprint(promptWriter, " y\n")
_, err := fmt.Fprintln(promptWriter, " y")
return err
}, promptResult{true, nil}},
{"reader closed", func() error {