Skip to content

Commit dc5a450

Browse files
committed
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>
1 parent cd6d902 commit dc5a450

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

cli/command/cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (cli *DockerCli) CurrentVersion() string {
114114
// Client returns the APIClient
115115
func (cli *DockerCli) Client() client.APIClient {
116116
if err := cli.initialize(); err != nil {
117-
_, _ = fmt.Fprintf(cli.Err(), "Failed to initialize: %s\n", err)
117+
_, _ = fmt.Fprintln(cli.Err(), "Failed to initialize:", err)
118118
os.Exit(1)
119119
}
120120
return cli.client
@@ -475,7 +475,7 @@ func (cli *DockerCli) DockerEndpoint() docker.Endpoint {
475475
if err := cli.initialize(); err != nil {
476476
// Note that we're not terminating here, as this function may be used
477477
// in cases where we're able to continue.
478-
_, _ = fmt.Fprintf(cli.Err(), "%v\n", cli.initErr)
478+
_, _ = fmt.Fprintln(cli.Err(), cli.initErr)
479479
}
480480
return cli.dockerEndpoint
481481
}

cli/command/utils_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,19 @@ func TestPromptForConfirmation(t *testing.T) {
177177
return nil
178178
}, promptResult{false, command.ErrPromptTerminated}},
179179
{"no", func() error {
180-
_, err := fmt.Fprint(promptWriter, "n\n")
180+
_, err := fmt.Fprintln(promptWriter, "n")
181181
return err
182182
}, promptResult{false, nil}},
183183
{"yes", func() error {
184-
_, err := fmt.Fprint(promptWriter, "y\n")
184+
_, err := fmt.Fprintln(promptWriter, "y")
185185
return err
186186
}, promptResult{true, nil}},
187187
{"any", func() error {
188-
_, err := fmt.Fprint(promptWriter, "a\n")
188+
_, err := fmt.Fprintln(promptWriter, "a")
189189
return err
190190
}, promptResult{false, nil}},
191191
{"with space", func() error {
192-
_, err := fmt.Fprint(promptWriter, " y\n")
192+
_, err := fmt.Fprintln(promptWriter, " y")
193193
return err
194194
}, promptResult{true, nil}},
195195
{"reader closed", func() error {

0 commit comments

Comments
 (0)