From 66d1a7a6f940a81ade651cd6cf17877912dbff3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Wed, 22 Mar 2023 22:01:00 +0000 Subject: [PATCH] add Go 1.20, drop 1.18 While here, clean up code to support older versions of Go. Note that none of these changes should explicitly break Go 1.18. --- .github/workflows/test.yml | 4 ++-- cmd/testscript/testdata/env_var_with_go.txt | 6 ++---- fmtsort/mapelem.go | 3 --- fmtsort/mapelem_1.11.go | 24 --------------------- go.mod | 2 +- goproxytest/testdata/list.txt | 3 --- testscript/exe_go118.go | 3 --- testscript/exe_pre_go1.18.go | 12 ----------- 8 files changed, 5 insertions(+), 52 deletions(-) delete mode 100644 fmtsort/mapelem_1.11.go delete mode 100644 testscript/exe_pre_go1.18.go diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f50a0036..121f549b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,8 +12,8 @@ jobs: fail-fast: false matrix: go-version: - - '1.18.x' - '1.19.x' + - '1.20.x' os: - ubuntu-latest - macos-11 @@ -32,7 +32,7 @@ jobs: go test -race ./... - name: Tidy - if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.19.x' # no need to do this everywhere + if: matrix.os == 'ubuntu-latest' && matrix.go-version == '1.20.x' # no need to do this everywhere run: | go mod tidy diff --git a/cmd/testscript/testdata/env_var_with_go.txt b/cmd/testscript/testdata/env_var_with_go.txt index cf445cac..aa23111e 100644 --- a/cmd/testscript/testdata/env_var_with_go.txt +++ b/cmd/testscript/testdata/env_var_with_go.txt @@ -13,8 +13,7 @@ unquote withproxy.txt testscript -v noproxy.txt stdout ^BANANA=$ stdout '^GOPATH=\$WORK[/\\]\.gopath'$ -[!go1.13] stdout ^GOPROXY=$ -[go1.13] stdout ^GOPROXY=https://proxy.golang.org,direct$ +stdout ^GOPROXY=https://proxy.golang.org,direct$ ! stderr .+ env BANANA=banana @@ -26,8 +25,7 @@ env GOPROXY= testscript -v noproxy.txt stdout ^BANANA=$ stdout '^GOPATH=\$WORK[/\\]\.gopath'$ -[!go1.13] stdout ^GOPROXY=$ -[go1.13] stdout ^GOPROXY=https://proxy.golang.org,direct$ +stdout ^GOPROXY=https://proxy.golang.org,direct$ ! stderr .+ # no GOPROXY, no pass-through, with proxy diff --git a/fmtsort/mapelem.go b/fmtsort/mapelem.go index 4e4c2945..98e4e38f 100644 --- a/fmtsort/mapelem.go +++ b/fmtsort/mapelem.go @@ -1,6 +1,3 @@ -//go:build go1.12 -// +build go1.12 - package fmtsort import "reflect" diff --git a/fmtsort/mapelem_1.11.go b/fmtsort/mapelem_1.11.go deleted file mode 100644 index 873bf7f5..00000000 --- a/fmtsort/mapelem_1.11.go +++ /dev/null @@ -1,24 +0,0 @@ -//go:build !go1.12 -// +build !go1.12 - -package fmtsort - -import "reflect" - -const brokenNaNs = true - -func mapElems(mapValue reflect.Value) ([]reflect.Value, []reflect.Value) { - key := mapValue.MapKeys() - value := make([]reflect.Value, 0, len(key)) - for _, k := range key { - v := mapValue.MapIndex(k) - if !v.IsValid() { - // Note: we can't retrieve the value, probably because - // the key is NaN, so just do the best we can and - // add a zero value of the correct type in that case. - v = reflect.Zero(mapValue.Type().Elem()) - } - value = append(value, v) - } - return key, value -} diff --git a/go.mod b/go.mod index 0a3a9970..1f9a6833 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/rogpeppe/go-internal -go 1.18 +go 1.19 diff --git a/goproxytest/testdata/list.txt b/goproxytest/testdata/list.txt index 8b05a178..d9b7da9e 100644 --- a/goproxytest/testdata/list.txt +++ b/goproxytest/testdata/list.txt @@ -1,6 +1,3 @@ -# prior to go 1.12 you cannot list a module without a requirement -[!go1.12] go get fruit.com - go list -m -versions fruit.com stdout 'v1.0.0 v1.1.0' diff --git a/testscript/exe_go118.go b/testscript/exe_go118.go index f65a5527..a9bdd810 100644 --- a/testscript/exe_go118.go +++ b/testscript/exe_go118.go @@ -1,6 +1,3 @@ -//go:build go1.18 -// +build go1.18 - package testscript import ( diff --git a/testscript/exe_pre_go1.18.go b/testscript/exe_pre_go1.18.go deleted file mode 100644 index e9323a22..00000000 --- a/testscript/exe_pre_go1.18.go +++ /dev/null @@ -1,12 +0,0 @@ -//go:build !go1.18 -// +build !go1.18 - -package testscript - -import ( - "testing" -) - -func mainStart() *testing.M { - return testing.MainStart(nopTestDeps{}, nil, nil, nil) -}