Skip to content

Commit 19557f8

Browse files
committed
fix some errCheck warnings, and update examples
- Explicitly suppress some unhandled errors - Use "pass" credentials helper in examples, which is available on more platforms than "secretservice" (only supporte on Linux) - Update domain and username in examples. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 94483d2 commit 19557f8

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

client/client_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@ func mockProgramFn(args ...string) Program {
9292
}
9393

9494
func ExampleStore() {
95-
p := NewShellProgramFunc("docker-credential-secretservice")
95+
p := NewShellProgramFunc("docker-credential-pass")
9696

9797
c := &credentials.Credentials{
98-
ServerURL: "https://example.com",
99-
Username: "calavera",
98+
ServerURL: "https://registry.example.com",
99+
Username: "exampleuser",
100100
Secret: "my super secret token",
101101
}
102102

103103
if err := Store(p, c); err != nil {
104-
fmt.Println(err)
104+
_, _ = fmt.Println(err)
105105
}
106106
}
107107

@@ -129,14 +129,14 @@ func TestStore(t *testing.T) {
129129
}
130130

131131
func ExampleGet() {
132-
p := NewShellProgramFunc("docker-credential-secretservice")
132+
p := NewShellProgramFunc("docker-credential-pass")
133133

134-
creds, err := Get(p, "https://example.com")
134+
creds, err := Get(p, "https://registry.example.com")
135135
if err != nil {
136-
fmt.Println(err)
136+
_, _ = fmt.Println(err)
137137
}
138138

139-
fmt.Printf("Got credentials for user `%s` in `%s`\n", creds.Username, creds.ServerURL)
139+
_, _ = fmt.Printf("Got credentials for user `%s` in `%s`\n", creds.Username, creds.ServerURL)
140140
}
141141

142142
func TestGet(t *testing.T) {
@@ -190,10 +190,10 @@ func TestGet(t *testing.T) {
190190
}
191191

192192
func ExampleErase() {
193-
p := NewShellProgramFunc("docker-credential-secretservice")
193+
p := NewShellProgramFunc("docker-credential-pass")
194194

195-
if err := Erase(p, "https://example.com"); err != nil {
196-
fmt.Println(err)
195+
if err := Erase(p, "https://registry.example.com"); err != nil {
196+
_, _ = fmt.Println(err)
197197
}
198198
}
199199

credentials/credentials.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func Serve(helper Helper) {
5959
}
6060

6161
if err != nil {
62-
fmt.Fprintf(os.Stdout, "%v\n", err)
62+
_, _ = fmt.Fprintln(os.Stdout, err)
6363
os.Exit(1)
6464
}
6565
}
@@ -143,7 +143,7 @@ func Get(helper Helper, reader io.Reader, writer io.Writer) error {
143143
return err
144144
}
145145

146-
fmt.Fprint(writer, buffer.String())
146+
_, _ = fmt.Fprint(writer, buffer.String())
147147
return nil
148148
}
149149

@@ -181,6 +181,6 @@ func List(helper Helper, writer io.Writer) error {
181181

182182
// PrintVersion outputs the current version.
183183
func PrintVersion(writer io.Writer) error {
184-
fmt.Fprintf(writer, "%s (%s) %s\n", Name, Package, Version)
184+
_, _ = fmt.Fprintf(writer, "%s (%s) %s\n", Name, Package, Version)
185185
return nil
186186
}

0 commit comments

Comments
 (0)