Skip to content

Commit 8d76d00

Browse files
committed
style: reformat all go files
activate go linter
1 parent ab1db71 commit 8d76d00

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+5077
-5034
lines changed

.github/workflows/linter.yml

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
go-fmt:
1818
name: Go Formatter
1919
runs-on: ubuntu-latest
20-
if: false # Pending activation
2120
steps:
2221
- uses: actions/checkout@v4
2322
- name: Set up Go

conn_timeout_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func _write(writer io.Writer, data []byte) error {
111111

112112
// Run the configured server. As soon as it returns, it is listening.
113113
// Returns a channel that receives a timeoutTestError on error, or is closed on successful completion.
114-
func (cfg *connTimeoutTestConfig) runServer(t *testing.T) (chan *timeoutTestError) {
114+
func (cfg *connTimeoutTestConfig) runServer(t *testing.T) chan *timeoutTestError {
115115
errorChan := make(chan *timeoutTestError)
116116
if cfg.endpoint != "" {
117117
// Only listen on localhost
@@ -307,7 +307,7 @@ var connTestConfigs = []connTimeoutTestConfig{
307307
serverToClientPayload: []byte("abc"),
308308
clientToServerPayload: []byte("defghi"),
309309

310-
failStep: testStepConnect,
310+
failStep: testStepConnect,
311311
failError: "i/o timeout",
312312
},
313313
// short session timeout, medium connect timeout, with connect to nonexistent endpoint.
@@ -326,7 +326,7 @@ var connTestConfigs = []connTimeoutTestConfig{
326326
serverToClientPayload: []byte("abc"),
327327
clientToServerPayload: []byte("defghi"),
328328

329-
failStep: testStepConnect,
329+
failStep: testStepConnect,
330330
failError: "i/o timeout",
331331
},
332332
// Get an IO timeout on the read.

lib/http/chunked.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,11 @@ func isASCIISpace(b byte) bool {
152152

153153
// removeChunkExtension removes any chunk-extension from p.
154154
// For example,
155-
// "0" => "0"
156-
// "0;token" => "0"
157-
// "0;token=val" => "0"
158-
// `0;token="quoted string"` => "0"
155+
//
156+
// "0" => "0"
157+
// "0;token" => "0"
158+
// "0;token=val" => "0"
159+
// `0;token="quoted string"` => "0"
159160
func removeChunkExtension(p []byte) ([]byte, error) {
160161
semi := bytes.IndexByte(p, ';')
161162
if semi == -1 {

lib/http/client.go

+37-38
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,20 @@ import (
3737
// When following redirects, the Client will forward all headers set on the
3838
// initial Request except:
3939
//
40-
// * when forwarding sensitive headers like "Authorization",
41-
// "WWW-Authenticate", and "Cookie" to untrusted targets.
42-
// These headers will be ignored when following a redirect to a domain
43-
// that is not a subdomain match or exact match of the initial domain.
44-
// For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com"
45-
// will forward the sensitive headers, but a redirect to "bar.com" will not.
46-
//
47-
// * when forwarding the "Cookie" header with a non-nil cookie Jar.
48-
// Since each redirect may mutate the state of the cookie jar,
49-
// a redirect may possibly alter a cookie set in the initial request.
50-
// When forwarding the "Cookie" header, any mutated cookies will be omitted,
51-
// with the expectation that the Jar will insert those mutated cookies
52-
// with the updated values (assuming the origin matches).
53-
// If Jar is nil, the initial cookies are forwarded without change.
54-
//
40+
// - when forwarding sensitive headers like "Authorization",
41+
// "WWW-Authenticate", and "Cookie" to untrusted targets.
42+
// These headers will be ignored when following a redirect to a domain
43+
// that is not a subdomain match or exact match of the initial domain.
44+
// For example, a redirect from "foo.com" to either "foo.com" or "sub.foo.com"
45+
// will forward the sensitive headers, but a redirect to "bar.com" will not.
46+
//
47+
// - when forwarding the "Cookie" header with a non-nil cookie Jar.
48+
// Since each redirect may mutate the state of the cookie jar,
49+
// a redirect may possibly alter a cookie set in the initial request.
50+
// When forwarding the "Cookie" header, any mutated cookies will be omitted,
51+
// with the expectation that the Jar will insert those mutated cookies
52+
// with the updated values (assuming the origin matches).
53+
// If Jar is nil, the initial cookies are forwarded without change.
5554
type Client struct {
5655
// Transport specifies the mechanism by which individual
5756
// HTTP requests are made.
@@ -344,11 +343,11 @@ func basicAuth(username, password string) string {
344343
// the following redirect codes, Get follows the redirect, up to a
345344
// maximum of 10 redirects:
346345
//
347-
// 301 (Moved Permanently)
348-
// 302 (Found)
349-
// 303 (See Other)
350-
// 307 (Temporary Redirect)
351-
// 308 (Permanent Redirect)
346+
// 301 (Moved Permanently)
347+
// 302 (Found)
348+
// 303 (See Other)
349+
// 307 (Temporary Redirect)
350+
// 308 (Permanent Redirect)
352351
//
353352
// An error is returned if there were too many redirects or if there
354353
// was an HTTP protocol error. A non-2xx response doesn't cause an
@@ -373,11 +372,11 @@ func (c *Client) Get(url string) (r *Response, err error) {
373372
// following redirect codes, Get follows the redirect after calling the
374373
// Client's CheckRedirect function:
375374
//
376-
// 301 (Moved Permanently)
377-
// 302 (Found)
378-
// 303 (See Other)
379-
// 307 (Temporary Redirect)
380-
// 308 (Permanent Redirect)
375+
// 301 (Moved Permanently)
376+
// 302 (Found)
377+
// 303 (See Other)
378+
// 307 (Temporary Redirect)
379+
// 308 (Permanent Redirect)
381380
//
382381
// An error is returned if the Client's CheckRedirect function fails
383382
// or if there was an HTTP protocol error. A non-2xx response doesn't
@@ -770,11 +769,11 @@ func (c *Client) PostForm(url string, data url.Values) (resp *Response, err erro
770769
// the following redirect codes, Head follows the redirect, up to a
771770
// maximum of 10 redirects:
772771
//
773-
// 301 (Moved Permanently)
774-
// 302 (Found)
775-
// 303 (See Other)
776-
// 307 (Temporary Redirect)
777-
// 308 (Permanent Redirect)
772+
// 301 (Moved Permanently)
773+
// 302 (Found)
774+
// 303 (See Other)
775+
// 307 (Temporary Redirect)
776+
// 308 (Permanent Redirect)
778777
//
779778
// Head is a wrapper around DefaultClient.Head
780779
func Head(url string) (resp *Response, err error) {
@@ -785,11 +784,11 @@ func Head(url string) (resp *Response, err error) {
785784
// following redirect codes, Head follows the redirect after calling the
786785
// Client's CheckRedirect function:
787786
//
788-
// 301 (Moved Permanently)
789-
// 302 (Found)
790-
// 303 (See Other)
791-
// 307 (Temporary Redirect)
792-
// 308 (Permanent Redirect)
787+
// 301 (Moved Permanently)
788+
// 302 (Found)
789+
// 303 (See Other)
790+
// 307 (Temporary Redirect)
791+
// 308 (Permanent Redirect)
793792
func (c *Client) HeadWithHost(url, host string) (resp *Response, err error) {
794793
req, err := NewRequestWithHost("HEAD", url, host, nil)
795794
if err != nil {
@@ -803,9 +802,9 @@ func (c *Client) Head(url string) (resp *Response, err error) {
803802
}
804803

805804
// cancelTimerBody is an io.ReadCloser that wraps rc with two features:
806-
// 1) on Read error or close, the stop func is called.
807-
// 2) On Read failure, if reqDidTimeout is true, the error is wrapped and
808-
// marked as net.Error that hit its timeout.
805+
// 1. on Read error or close, the stop func is called.
806+
// 2. On Read failure, if reqDidTimeout is true, the error is wrapped and
807+
// marked as net.Error that hit its timeout.
809808
type cancelTimerBody struct {
810809
stop func() // stops the time.Timer waiting to cancel the request
811810
rc io.ReadCloser

lib/http/client_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1067,9 +1067,9 @@ func TestClientHeadContentLength_h1(t *testing.T) {
10671067
}
10681068

10691069
/*
1070-
func TestClientHeadContentLength_h2(t *testing.T) {
1071-
testClientHeadContentLength(t, h2Mode)
1072-
}
1070+
func TestClientHeadContentLength_h2(t *testing.T) {
1071+
testClientHeadContentLength(t, h2Mode)
1072+
}
10731073
*/
10741074
func testClientHeadContentLength(t *testing.T, h2 bool) {
10751075
defer afterTest(t)
@@ -1379,7 +1379,7 @@ func TestClientTimeoutCancel(t *testing.T) {
13791379

13801380
func TestClientRedirectEatsBody_h1(t *testing.T) { testClientRedirectEatsBody(t, h1Mode) }
13811381

1382-
//func TestClientRedirectEatsBody_h2(t *testing.T) { testClientRedirectEatsBody(t, h2Mode) }
1382+
// func TestClientRedirectEatsBody_h2(t *testing.T) { testClientRedirectEatsBody(t, h2Mode) }
13831383
func testClientRedirectEatsBody(t *testing.T, h2 bool) {
13841384
setParallel(t)
13851385
defer afterTest(t)

0 commit comments

Comments
 (0)