From 679c4baead9267317ca002a4c7703b130b2533e5 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 29 Oct 2020 10:16:17 +0700 Subject: [PATCH 1/3] run gofumpt, add gofumpt linter --- .golangci.yml | 3 +- encoder.go | 1 - integrationtests/interop/interop_test.go | 1 - static_table.go | 50 +++++++++++++++--------- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 35e4fdd..41d4746 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,7 +5,8 @@ linters: enable: - deadcode - goconst - - gofmt + - gofmt # redundant, since gofmt *should* be a no-op after gofumpt + - gofumpt - goimports - gosimple - ineffassign diff --git a/encoder.go b/encoder.go index febf61d..13e0ad2 100644 --- a/encoder.go +++ b/encoder.go @@ -47,7 +47,6 @@ func (e *Encoder) WriteField(f HeaderField) error { e.writeLiteralFieldWithNameReference(&f, idxAndVals.idx) } } - } else { e.writeLiteralFieldWithoutNameReference(f) } diff --git a/integrationtests/interop/interop_test.go b/integrationtests/interop/interop_test.go index a1cc97e..90c5a66 100644 --- a/integrationtests/interop/interop_test.go +++ b/integrationtests/interop/interop_test.go @@ -24,7 +24,6 @@ func currentDir() string { } var _ = Describe("Interop", func() { - // find all encoded files with a dynamic table size of 0 findFiles := func() []string { var files []string diff --git a/static_table.go b/static_table.go index bdb2b5b..930e83c 100644 --- a/static_table.go +++ b/static_table.go @@ -142,10 +142,12 @@ var encoderMap = map[string]indexAndValues{ "HEAD": 18, "OPTIONS": 19, "POST": 20, - "PUT": 21}}, + "PUT": 21, + }}, ":scheme": {22, map[string]uint8{ "http": 22, - "https": 23}}, + "https": 23, + }}, ":status": {24, map[string]uint8{ "103": 24, "200": 25, @@ -160,16 +162,19 @@ var encoderMap = map[string]indexAndValues{ "403": 68, "421": 69, "425": 70, - "500": 71}}, + "500": 71, + }}, "accept": {29, map[string]uint8{ "*/*": 29, - "application/dns-message": 30}}, + "application/dns-message": 30, + }}, "accept-encoding": {31, map[string]uint8{"gzip, deflate, br": 31}}, "accept-ranges": {32, map[string]uint8{"bytes": 32}}, "access-control-allow-headers": {33, map[string]uint8{ "cache-control": 33, "content-type": 34, - "*": 75}}, + "*": 75, + }}, "access-control-allow-origin": {35, map[string]uint8{"*": 35}}, "cache-control": {36, map[string]uint8{ "max-age=0": 36, @@ -177,10 +182,12 @@ var encoderMap = map[string]indexAndValues{ "max-age=604800": 38, "no-cache": 39, "no-store": 40, - "public, max-age=31536000": 41}}, + "public, max-age=31536000": 41, + }}, "content-encoding": {42, map[string]uint8{ "br": 42, - "gzip": 43}}, + "gzip": 43, + }}, "content-type": {44, map[string]uint8{ "application/dns-message": 44, "application/javascript": 45, @@ -192,39 +199,43 @@ var encoderMap = map[string]indexAndValues{ "text/css": 51, "text/html; charset=utf-8": 52, "text/plain": 53, - "text/plain;charset=utf-8": 54}}, + "text/plain;charset=utf-8": 54, + }}, "range": {55, map[string]uint8{"bytes=0-": 55}}, "strict-transport-security": {56, map[string]uint8{ "max-age=31536000": 56, "max-age=31536000; includesubdomains": 57, - "max-age=31536000; includesubdomains; preload": 58}}, + "max-age=31536000; includesubdomains; preload": 58, + }}, "vary": {59, map[string]uint8{ "accept-encoding": 59, - "origin": 60}}, + "origin": 60, + }}, "x-content-type-options": {61, map[string]uint8{"nosniff": 61}}, "x-xss-protection": {62, map[string]uint8{"1; mode=block": 62}}, // ":status" is duplicated and takes index 63 to 71 "accept-language": {72, nil}, "access-control-allow-credentials": {73, map[string]uint8{ "FALSE": 73, - "TRUE": 74}}, + "TRUE": 74, + }}, // "access-control-allow-headers" is duplicated and takes index 75 "access-control-allow-methods": {76, map[string]uint8{ "get": 76, "get, post, options": 77, - "options": 78}}, - "access-control-expose-headers": {79, map[string]uint8{ - "content-length": 79, + "options": 78, }}, - "access-control-request-headers": {80, map[string]uint8{ - "content-type": 80}}, + "access-control-expose-headers": {79, map[string]uint8{"content-length": 79}}, + "access-control-request-headers": {80, map[string]uint8{"content-type": 80}}, "access-control-request-method": {81, map[string]uint8{ "get": 81, - "post": 82}}, + "post": 82, + }}, "alt-svc": {83, map[string]uint8{"clear": 83}}, "authorization": {84, nil}, "content-security-policy": {85, map[string]uint8{ - "script-src 'none'; object-src 'none'; base-uri 'none'": 85}}, + "script-src 'none'; object-src 'none'; base-uri 'none'": 85, + }}, "early-data": {86, map[string]uint8{"1": 86}}, "expect-ct": {87, nil}, "forwarded": {88, nil}, @@ -238,5 +249,6 @@ var encoderMap = map[string]indexAndValues{ "x-forwarded-for": {96, nil}, "x-frame-options": {97, map[string]uint8{ "deny": 97, - "sameorigin": 98}}, + "sameorigin": 98, + }}, } From 25e3386b0dd2acc24121cc1c8378ace8c023ccff Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 29 Oct 2020 10:17:14 +0700 Subject: [PATCH 2/3] enable the asciicheck, exhaustive and exportloopref linters --- .golangci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.golangci.yml b/.golangci.yml index 41d4746..4a91adc 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -3,7 +3,10 @@ linters-settings: linters: disable-all: true enable: + - asciicheck - deadcode + - exhaustive + - exportloopref - goconst - gofmt # redundant, since gofmt *should* be a no-op after gofumpt - gofumpt From 9b4bf02c3ffa5a7a9867593282cdd7f632dbbf8f Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 29 Oct 2020 10:17:33 +0700 Subject: [PATCH 3/3] update golangci-lint to v1.32 --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 124d14c..9de7e48 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,4 +16,4 @@ jobs: uses: golangci/golangci-lint-action@v1 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.30 + version: v1.32