Skip to content

Commit 10c8ebb

Browse files
authored
refactor: bump minimum required Go version to 1.24.0 (#142)
We always keep the minimum Go version requirement in sync with `golang.org/x/mod` to ensure we don't fall too far behind on new Go features. Signed-off-by: Aofei Sheng <[email protected]>
1 parent 9ff4639 commit 10c8ebb

File tree

9 files changed

+77
-90
lines changed

9 files changed

+77
-90
lines changed

.github/workflows/test.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ jobs:
88
strategy:
99
matrix:
1010
go:
11-
- 1.23.x
1211
- 1.24.x
1312
- 1.25.x
1413
steps:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ those who want to build their own proxies.
4646
docker pull ghcr.io/goproxy/goproxy
4747
```
4848

49-
## Quick Start
49+
## Quickstart
5050

5151
<details><summary>Write code</summary>
5252

cacher_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package goproxy
22

33
import (
4-
"context"
54
"errors"
65
"io"
76
"io/fs"
@@ -15,7 +14,7 @@ func TestDirCacher(t *testing.T) {
1514
t.Run("Normal", func(t *testing.T) {
1615
dirCacher := DirCacher(t.TempDir())
1716

18-
if err := dirCacher.Put(context.Background(), "a/b/c", strings.NewReader("foobar")); err != nil {
17+
if err := dirCacher.Put(t.Context(), "a/b/c", strings.NewReader("foobar")); err != nil {
1918
t.Fatalf("unexpected error %v", err)
2019
}
2120

@@ -31,7 +30,7 @@ func TestDirCacher(t *testing.T) {
3130
t.Errorf("got %d, want %d", got, want)
3231
}
3332

34-
if rc, err := dirCacher.Get(context.Background(), "a/b/c"); err != nil {
33+
if rc, err := dirCacher.Get(t.Context(), "a/b/c"); err != nil {
3534
t.Errorf("unexpected error %v", err)
3635
} else if rc == nil {
3736
t.Error("unexpected nil")
@@ -47,7 +46,7 @@ func TestDirCacher(t *testing.T) {
4746
t.Run("GetNonExistentFile", func(t *testing.T) {
4847
dirCacher := DirCacher(t.TempDir())
4948

50-
rc, err := dirCacher.Get(context.Background(), "a/b/c")
49+
rc, err := dirCacher.Get(t.Context(), "a/b/c")
5150
if err == nil {
5251
t.Fatal("expected error")
5352
}
@@ -63,7 +62,7 @@ func TestDirCacher(t *testing.T) {
6362
dirCacher := DirCacher(t.TempDir())
6463
errRead := errors.New("cannot read")
6564

66-
err := dirCacher.Put(context.Background(), "d/e/f", &testReadSeeker{
65+
err := dirCacher.Put(t.Context(), "d/e/f", &testReadSeeker{
6766
ReadSeeker: strings.NewReader("foobar"),
6867
read: func(rs io.ReadSeeker, p []byte) (n int, err error) {
6968
return 0, errRead
@@ -87,7 +86,7 @@ func TestDirCacher(t *testing.T) {
8786
}
8887
dirCacher := DirCacher(filepath.Join(cacheDir, filepath.FromSlash("a/b/c")))
8988

90-
err := dirCacher.Put(context.Background(), "d/e/f", strings.NewReader("foobar"))
89+
err := dirCacher.Put(t.Context(), "d/e/f", strings.NewReader("foobar"))
9190
if err == nil {
9291
t.Fatal("expected error")
9392
}

fetcher.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,9 +531,9 @@ func (gf *GoFetcher) execGo(ctx context.Context, args ...string) ([]byte, error)
531531
return nil, err
532532
}
533533
var msg string
534-
for _, line := range strings.Split(string(output), "\n") {
534+
for line := range strings.Lines(string(output)) {
535535
if !strings.HasPrefix(line, "go: finding") {
536-
msg += line + "\n"
536+
msg += line
537537
}
538538
}
539539
msg = strings.TrimPrefix(msg, "go: ")

fetcher_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ func TestGoFetcherQuery(t *testing.T) {
244244
gf.initOnce.Do(gf.init)
245245
gf.env = append(gf.env, "GOPROXY="+proxyServer.URL+"/direct/")
246246

247-
version, time, err := gf.Query(context.Background(), tt.path, "latest")
247+
version, time, err := gf.Query(t.Context(), tt.path, "latest")
248248
if tt.wantErr != nil {
249249
if err == nil {
250250
t.Fatal("expected error")
@@ -338,7 +338,7 @@ func TestGoFetcherProxyQuery(t *testing.T) {
338338
if err != nil {
339339
t.Fatalf("unexpected error %v", err)
340340
}
341-
version, time, err := gf.proxyQuery(context.Background(), tt.path, tt.query, proxy)
341+
version, time, err := gf.proxyQuery(t.Context(), tt.path, tt.query, proxy)
342342
if tt.wantErr != nil {
343343
if err == nil {
344344
t.Fatal("expected error")
@@ -398,7 +398,7 @@ func TestGoFetcherDirectQuery(t *testing.T) {
398398
}
399399
gf.env = append(gf.env, "GOPROXY="+proxyServer.URL)
400400

401-
version, time, err := gf.directQuery(context.Background(), tt.path, "latest")
401+
version, time, err := gf.directQuery(t.Context(), tt.path, "latest")
402402
if tt.wantErr != nil {
403403
if err == nil {
404404
t.Fatal("expected error")
@@ -523,7 +523,7 @@ invalid
523523
gf.initOnce.Do(gf.init)
524524
gf.env = append(gf.env, "GOPROXY="+proxyServer.URL+"/direct/")
525525

526-
versions, err := gf.List(context.Background(), tt.path)
526+
versions, err := gf.List(t.Context(), tt.path)
527527
if tt.wantErr != nil {
528528
if err == nil {
529529
t.Fatal("expected error")
@@ -588,7 +588,7 @@ func TestGoFetcherProxyList(t *testing.T) {
588588
if err != nil {
589589
t.Fatalf("unexpected error %v", err)
590590
}
591-
versions, err := gf.proxyList(context.Background(), tt.path, proxy)
591+
versions, err := gf.proxyList(t.Context(), tt.path, proxy)
592592
if tt.wantErr != nil {
593593
if err == nil {
594594
t.Fatal("expected error")
@@ -652,7 +652,7 @@ func TestGoFetcherDirectList(t *testing.T) {
652652
}
653653
gf.env = append(gf.env, "GOPROXY="+proxyServer.URL)
654654

655-
versions, err := gf.directList(context.Background(), tt.path)
655+
versions, err := gf.directList(t.Context(), tt.path)
656656
if tt.wantErr != nil {
657657
if err == nil {
658658
t.Fatal("expected error")
@@ -937,7 +937,7 @@ func TestGoFetcherDownload(t *testing.T) {
937937
gf.initOnce.Do(gf.init)
938938
gf.env = append(gf.env, "GOPROXY="+proxyServer.URL+"/direct/")
939939

940-
info, mod, zip, err := gf.Download(context.Background(), tt.path, tt.version)
940+
info, mod, zip, err := gf.Download(t.Context(), tt.path, tt.version)
941941
if tt.wantErr != nil {
942942
if err == nil {
943943
t.Fatal("expected error")
@@ -1089,7 +1089,7 @@ func TestGoFetcherProxyDownload(t *testing.T) {
10891089
if err != nil {
10901090
t.Fatalf("unexpected error %v", err)
10911091
}
1092-
infoFile, modFile, zipFile, cleanup, err := gf.proxyDownload(context.Background(), tt.path, tt.version, proxy)
1092+
infoFile, modFile, zipFile, cleanup, err := gf.proxyDownload(t.Context(), tt.path, tt.version, proxy)
10931093
if tt.wantErr != nil {
10941094
if err == nil {
10951095
t.Fatal("expected error")
@@ -1193,7 +1193,7 @@ func TestGoFetcherDirectDownload(t *testing.T) {
11931193
}
11941194
gf.env = append(gf.env, "GOPROXY="+proxyServer.URL)
11951195

1196-
infoFile, modFile, zipFile, err := gf.directDownload(context.Background(), tt.path, infoVersion)
1196+
infoFile, modFile, zipFile, err := gf.directDownload(t.Context(), tt.path, infoVersion)
11971197
if tt.wantErr != nil {
11981198
if err == nil {
11991199
t.Fatal("expected error")
@@ -1239,7 +1239,7 @@ func (misbehavingDoneContext) Value(key any) any { return nil }
12391239
func TestGoFetcherExecGo(t *testing.T) {
12401240
t.Setenv("GOMODCACHE", t.TempDir())
12411241

1242-
ctxCanceled, cancel := context.WithCancel(context.Background())
1242+
ctxCanceled, cancel := context.WithCancel(t.Context())
12431243
cancel()
12441244

12451245
for _, tt := range []struct {
@@ -1254,19 +1254,19 @@ func TestGoFetcherExecGo(t *testing.T) {
12541254
}{
12551255
{
12561256
n: 1,
1257-
ctx: context.Background(),
1257+
ctx: t.Context(),
12581258
args: []string{"env", "GOPROXY"},
12591259
wantOutput: "direct\n",
12601260
},
12611261
{
12621262
n: 2,
1263-
ctx: context.Background(),
1263+
ctx: t.Context(),
12641264
args: []string{"foobar"},
12651265
wantErr: errors.New("go foobar: unknown command\nRun 'go help' for usage."),
12661266
},
12671267
{
12681268
n: 3,
1269-
ctx: context.Background(),
1269+
ctx: t.Context(),
12701270
args: []string{"mod", "download", "-json", "foobar@latest"},
12711271
wantErr: errors.New(`foobar@latest: malformed module path "foobar": missing dot in first path element`),
12721272
},
@@ -1282,7 +1282,7 @@ func TestGoFetcherExecGo(t *testing.T) {
12821282
},
12831283
{
12841284
n: 6,
1285-
ctx: context.Background(),
1285+
ctx: t.Context(),
12861286
tempDir: filepath.Join(t.TempDir(), "404"),
12871287
wantErr: fs.ErrNotExist,
12881288
},

go.mod

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
module github.com/goproxy/goproxy
22

3-
go 1.23.0
3+
go 1.24.0
44

55
require (
6-
github.com/minio/minio-go/v7 v7.0.93
7-
github.com/spf13/cobra v1.9.1
8-
golang.org/x/mod v0.25.0
6+
github.com/minio/minio-go/v7 v7.0.95
7+
github.com/spf13/cobra v1.10.1
8+
golang.org/x/mod v0.28.0
99
)
1010

1111
require (
@@ -16,16 +16,16 @@ require (
1616
github.com/google/uuid v1.6.0 // indirect
1717
github.com/inconshreveable/mousetrap v1.1.0 // indirect
1818
github.com/klauspost/compress v1.18.0 // indirect
19-
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
20-
github.com/minio/crc64nvme v1.0.1 // indirect
19+
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
20+
github.com/minio/crc64nvme v1.0.2 // indirect
2121
github.com/minio/md5-simd v1.1.2 // indirect
22-
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c // indirect
22+
github.com/philhofer/fwd v1.2.0 // indirect
2323
github.com/pmezard/go-difflib v1.0.0 // indirect
2424
github.com/rs/xid v1.6.0 // indirect
25-
github.com/spf13/pflag v1.0.6 // indirect
25+
github.com/spf13/pflag v1.0.9 // indirect
2626
github.com/tinylib/msgp v1.3.0 // indirect
27-
golang.org/x/crypto v0.36.0 // indirect
28-
golang.org/x/net v0.38.0 // indirect
29-
golang.org/x/sys v0.31.0 // indirect
30-
golang.org/x/text v0.23.0 // indirect
27+
golang.org/x/crypto v0.39.0 // indirect
28+
golang.org/x/net v0.41.0 // indirect
29+
golang.org/x/sys v0.33.0 // indirect
30+
golang.org/x/text v0.26.0 // indirect
3131
)

go.sum

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,41 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf
1414
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
1515
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
1616
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
17-
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
18-
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
19-
github.com/minio/crc64nvme v1.0.1 h1:DHQPrYPdqK7jQG/Ls5CTBZWeex/2FMS3G5XGkycuFrY=
20-
github.com/minio/crc64nvme v1.0.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
17+
github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU=
18+
github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
19+
github.com/minio/crc64nvme v1.0.2 h1:6uO1UxGAD+kwqWWp7mBFsi5gAse66C4NXO8cmcVculg=
20+
github.com/minio/crc64nvme v1.0.2/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
2121
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
2222
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
23-
github.com/minio/minio-go/v7 v7.0.93 h1:lAB4QJp8Nq3vDMOU0eKgMuyBiEGMNlXQ5Glc8qAxqSU=
24-
github.com/minio/minio-go/v7 v7.0.93/go.mod h1:71t2CqDt3ThzESgZUlU1rBN54mksGGlkLcFgguDnnAc=
25-
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c h1:dAMKvw0MlJT1GshSTtih8C2gDs04w8dReiOGXrGLNoY=
26-
github.com/philhofer/fwd v1.1.3-0.20240916144458-20a13a1f6b7c/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
23+
github.com/minio/minio-go/v7 v7.0.95 h1:ywOUPg+PebTMTzn9VDsoFJy32ZuARN9zhB+K3IYEvYU=
24+
github.com/minio/minio-go/v7 v7.0.95/go.mod h1:wOOX3uxS334vImCNRVyIDdXX9OsXDm89ToynKgqUKlo=
25+
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
26+
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
2727
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
2828
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2929
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
3030
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
3131
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
32-
github.com/spf13/cobra v1.9.1 h1:CXSaggrXdbHK9CF+8ywj8Amf7PBRmPCOJugH954Nnlo=
33-
github.com/spf13/cobra v1.9.1/go.mod h1:nDyEzZ8ogv936Cinf6g1RU9MRY64Ir93oCnqb9wxYW0=
34-
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
35-
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
32+
github.com/spf13/cobra v1.10.1 h1:lJeBwCfmrnXthfAupyUTzJ/J4Nc1RsHC/mSRU2dll/s=
33+
github.com/spf13/cobra v1.10.1/go.mod h1:7SmJGaTHFVBY0jW4NXGluQoLvhqFQM+6XSKD+P4XaB0=
34+
github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY=
35+
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
3636
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
3737
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
3838
github.com/tinylib/msgp v1.3.0 h1:ULuf7GPooDaIlbyvgAxBV/FI7ynli6LZ1/nVUNu+0ww=
3939
github.com/tinylib/msgp v1.3.0/go.mod h1:ykjzy2wzgrlvpDCRc4LA8UXy6D8bzMSuAF3WD57Gok0=
40-
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
41-
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
42-
golang.org/x/mod v0.25.0 h1:n7a+ZbQKQA/Ysbyb0/6IbB1H/X41mKgbhfv7AfG/44w=
43-
golang.org/x/mod v0.25.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww=
44-
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
45-
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
46-
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
47-
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
48-
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
49-
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
50-
golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA=
51-
golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c=
40+
golang.org/x/crypto v0.39.0 h1:SHs+kF4LP+f+p14esP5jAoDpHU8Gu/v9lFRK6IT5imM=
41+
golang.org/x/crypto v0.39.0/go.mod h1:L+Xg3Wf6HoL4Bn4238Z6ft6KfEpN0tJGo53AAPC632U=
42+
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
43+
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
44+
golang.org/x/net v0.41.0 h1:vBTly1HeNPEn3wtREYfy4GZ/NECgw2Cnl+nK6Nz3uvw=
45+
golang.org/x/net v0.41.0/go.mod h1:B/K4NNqkfmg07DQYrbwvSluqCJOOXwUjeb/5lOisjbA=
46+
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
47+
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
48+
golang.org/x/text v0.26.0 h1:P42AVeLghgTYr4+xUnTRKDMqpar+PtX7KWuNQL21L8M=
49+
golang.org/x/text v0.26.0/go.mod h1:QK15LZJUUQVJxhz7wXgxSy/CJaTFjd0G+YLonydOVQA=
50+
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
51+
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
5252
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
5353
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
5454
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 commit comments

Comments
 (0)