Skip to content

Commit 7cf81b8

Browse files
committed
fix formatting and error messages
1 parent 50efd9a commit 7cf81b8

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

cmd/src/main.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"encoding/json"
66
"flag"
7-
"fmt"
87
"io"
98
"log"
109
"net"
@@ -117,10 +116,10 @@ func parseEndpoint(endpoint string) (*url.URL, error) {
117116
return nil, err
118117
}
119118
if !(u.Scheme == "http" || u.Scheme == "https") {
120-
return nil, errors.Newf("Invalid scheme %s. Require http or https", u.Scheme)
119+
return nil, errors.Newf("invalid scheme %s: require http or https", u.Scheme)
121120
}
122121
if u.Host == "" {
123-
return nil, errors.Newf("Empty host")
122+
return nil, errors.Newf("empty host")
124123
}
125124
return u, nil
126125
}
@@ -273,20 +272,20 @@ func readConfig() (*config, error) {
273272
}
274273
isValidUDS, err := isValidUnixSocket(path)
275274
if err != nil {
276-
return nil, errors.Newf("Invalid proxy configuration: %w", err)
275+
return nil, errors.Newf("invalid proxy configuration: %w", err)
277276
}
278277
if !isValidUDS {
279278
return nil, errors.Newf("invalid proxy socket: %s", path)
280279
}
281280
cfg.proxyPath = path
282281
} else {
283-
return nil, errors.Newf("Invalid proxy endpoint: %s", proxyStr)
282+
return nil, errors.Newf("invalid proxy endpoint: %s", proxyStr)
284283
}
285284
} else {
286285
// no SRC_PROXY; check for the standard proxy env variables HTTP_PROXY, HTTPS_PROXY, and NO_PROXY
287286
if u, err := http.ProxyFromEnvironment(&http.Request{URL: cfg.endpointURL}); err != nil {
288287
// when there's an error, the value for the env variable is not a legit URL
289-
return nil, fmt.Errorf("Invalid HTTP_PROXY or HTTPS_PROXY value: %w", err)
288+
return nil, errors.Newf("invalid HTTP_PROXY or HTTPS_PROXY value: %w", err)
290289
} else {
291290
cfg.proxyURL = u
292291
}
@@ -321,7 +320,7 @@ func isValidUnixSocket(path string) (bool, error) {
321320
if os.IsNotExist(err) {
322321
return false, nil
323322
}
324-
return false, errors.Newf("Not a UNIX Domain Socket: %v: %w", path, err)
323+
return false, errors.Newf("not a UNIX domain socket: %v: %w", path, err)
325324
}
326325
defer conn.Close()
327326

cmd/src/search_stream_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"io"
66
"net"
77
"net/http"
8-
"net/url"
98
"net/http/httptest"
9+
"net/url"
1010
"os"
1111
"testing"
1212

0 commit comments

Comments
 (0)