From 7a902570cb17174de4ac788094f8ebedec136f57 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Sat, 2 Feb 2019 19:16:00 -0800 Subject: [PATCH] .travis.yml: bump to Go 1.11, use 'gofmt -s' (#92) * .travis.yml: Bump to modern Go (1.11) Go 1.11 came out in August [1], which means Go 1.9 and earlier are no longer supported [2]. Just test on supported versions. [1]: https://golang.org/doc/devel/release.html#go1.11 [2]: https://golang.org/doc/devel/release.html#policy * Revert "Remove simplify-code option, for now" This reverts commit be6978e2943923f8ece88a9a23d6d7a343edeeef (Remove simplify-code option, for now, 2016-03-12, #40). I expect this was due to a simplification change between Go versions (the commit message doesn't say), but none of the versions which we were using back then are supported any more. * httpcache: Update gofmt Generated with: $ gofmt -s -w *.go */*.go using: $ go version go version go1.11.2 linux/amd64 * .travis.yml: Only run 'gofmt' on 1.11.x The indent heuristic changed with Go 1.11 [1], so there's no single form that satisfies gofmt for both Go 1.10 and Go 1.11. With this commit, we now only run gofmt on 1.11. Docs for the 'include' syntax are in [2]. Also replace the double-diff with a 'gofmt -w ...' to write the changes and a 'git diff ...' call to display the changes and exit non-zero if there were any. [1]: https://golang.org/doc/go1.11#gofmt [2]: https://docs.travis-ci.com/user/customizing-the-build/#explicitly-including-jobs --- .travis.yml | 13 ++++++------- httpcache.go | 18 +++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index b5ffbe0..597bc99 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,18 @@ sudo: false language: go -go: - - 1.6.x - - 1.7.x - - 1.8.x - - 1.9.x - - master matrix: allow_failures: - go: master fast_finish: true + include: + - go: 1.10.x + - go: 1.11.x + env: GOFMT=1 + - go: master install: - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step). script: - go get -t -v ./... - - diff -u <(echo -n) <(gofmt -d .) + - if test -n "${GOFMT}"; then gofmt -w -s . && git diff --exit-code; fi - go tool vet . - go test -v -race ./... diff --git a/httpcache.go b/httpcache.go index f6a2ec4..b41a63d 100644 --- a/httpcache.go +++ b/httpcache.go @@ -416,14 +416,14 @@ func canStaleOnError(respHeaders, reqHeaders http.Header) bool { func getEndToEndHeaders(respHeaders http.Header) []string { // These headers are always hop-by-hop hopByHopHeaders := map[string]struct{}{ - "Connection": struct{}{}, - "Keep-Alive": struct{}{}, - "Proxy-Authenticate": struct{}{}, - "Proxy-Authorization": struct{}{}, - "Te": struct{}{}, - "Trailers": struct{}{}, - "Transfer-Encoding": struct{}{}, - "Upgrade": struct{}{}, + "Connection": {}, + "Keep-Alive": {}, + "Proxy-Authenticate": {}, + "Proxy-Authorization": {}, + "Te": {}, + "Trailers": {}, + "Transfer-Encoding": {}, + "Upgrade": {}, } for _, extra := range strings.Split(respHeaders.Get("connection"), ",") { @@ -433,7 +433,7 @@ func getEndToEndHeaders(respHeaders http.Header) []string { } } endToEndHeaders := []string{} - for respHeader, _ := range respHeaders { + for respHeader := range respHeaders { if _, ok := hopByHopHeaders[respHeader]; !ok { endToEndHeaders = append(endToEndHeaders, respHeader) }