Skip to content

Commit ee2fcaa

Browse files
authored
update dependencies and rely on Go 1.21 APIs (#256)
We had been using ancient versions of golang.org/x modules, which passed the tests but wasn't great as they contain bugs and most users would want their newer versions anyway. Assume Go 1.21 later; use slices.Compact and simplify a test. While here, update the setup-go action as well.
1 parent 1f3d244 commit ee2fcaa

File tree

5 files changed

+14
-23
lines changed

5 files changed

+14
-23
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Checkout code
2424
uses: actions/checkout@v4
2525
- name: Install Go
26-
uses: actions/setup-go@v4
26+
uses: actions/setup-go@v5
2727
with:
2828
go-version: ${{ matrix.go-version }}
2929
cache: false # our tests are quick enough

cmd/testscript/testdata/noproxy.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# With no .gomodproxy supporting files, we use the GOPROXY from
22
# the environment.
3-
# Note that Go 1.21 started quoting with single quotes in "go env",
4-
# where older versions used double quotes.
53
env GOPROXY=0.1.2.3
64
unquote file.txt
75
testscript -v file.txt
86

97
-- file.txt --
108
>go env
11-
>[!windows] stdout '^GOPROXY=[''"]0.1.2.3[''"]$'
9+
>[!windows] stdout '^GOPROXY=''0.1.2.3''$'
1210
>[windows] stdout '^set GOPROXY=0.1.2.3$'

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/rogpeppe/go-internal
33
go 1.21
44

55
require (
6-
golang.org/x/mod v0.9.0
7-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
8-
golang.org/x/tools v0.1.12
6+
golang.org/x/mod v0.18.0
7+
golang.org/x/sys v0.21.0
8+
golang.org/x/tools v0.22.0
99
)

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
2-
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
3-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
4-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
5-
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
6-
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
1+
golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0=
2+
golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
3+
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
4+
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
5+
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
6+
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=

testscript/testscript.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"path/filepath"
2222
"regexp"
2323
"runtime"
24-
"sort"
24+
"slices"
2525
"strings"
2626
"sync/atomic"
2727
"syscall"
@@ -754,15 +754,8 @@ func (ts *TestScript) cmdSuggestions(name string) []string {
754754
return nil
755755
}
756756
// deduplicate candidates
757-
// TODO: Use slices.Compact (and maybe slices.Sort) once we can use Go 1.21
758-
sort.Strings(candidates)
759-
out := candidates[:1]
760-
for _, c := range candidates[1:] {
761-
if out[len(out)-1] == c {
762-
out = append(out, c)
763-
}
764-
}
765-
return out
757+
slices.Sort(candidates)
758+
return slices.Compact(candidates)
766759
}
767760

768761
func (ts *TestScript) applyScriptUpdates() {

0 commit comments

Comments
 (0)