Skip to content

Commit 45ee571

Browse files
authored
Update to go 1.26.0 and golangci-lint 2.9.0 (#36588)
1 parent 3754e9d commit 45ee571

30 files changed

+95
-130
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22
# Build stage
3-
FROM docker.io/library/golang:1.25-alpine3.23 AS build-env
3+
FROM docker.io/library/golang:1.26-alpine3.23 AS build-env
44

55
ARG GOPROXY=direct
66

Dockerfile.rootless

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# syntax=docker/dockerfile:1
22
# Build stage
3-
FROM docker.io/library/golang:1.25-alpine3.23 AS build-env
3+
FROM docker.io/library/golang:1.26-alpine3.23 AS build-env
44

55
ARG GOPROXY=direct
66

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ XGO_VERSION := go-1.25.x
3232
AIR_PACKAGE ?= github.com/air-verse/air@v1
3333
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3
3434
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.9.2
35-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0
35+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0
3636
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.15
3737
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.7.0
3838
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
module code.gitea.io/gitea
22

3-
go 1.25.0
4-
5-
toolchain go1.25.7
3+
go 1.26.0
64

75
// rfc5280 said: "The serial number is an integer assigned by the CA to each certificate."
86
// But some CAs use negative serial number, just relax the check. related:

models/asymkey/gpg_key_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"code.gitea.io/gitea/models/unittest"
1212
user_model "code.gitea.io/gitea/models/user"
1313
"code.gitea.io/gitea/modules/timeutil"
14-
"code.gitea.io/gitea/modules/util"
1514

1615
"github.com/ProtonMail/go-crypto/openpgp"
1716
"github.com/ProtonMail/go-crypto/openpgp/packet"
@@ -398,7 +397,7 @@ epiDVQ==
398397
func TestTryGetKeyIDFromSignature(t *testing.T) {
399398
assert.Empty(t, TryGetKeyIDFromSignature(&packet.Signature{}))
400399
assert.Equal(t, "038D1A3EADDBEA9C", TryGetKeyIDFromSignature(&packet.Signature{
401-
IssuerKeyId: util.ToPointer(uint64(0x38D1A3EADDBEA9C)),
400+
IssuerKeyId: new(uint64(0x38D1A3EADDBEA9C)),
402401
}))
403402
assert.Equal(t, "038D1A3EADDBEA9C", TryGetKeyIDFromSignature(&packet.Signature{
404403
IssuerFingerprint: []uint8{0xb, 0x23, 0x24, 0xc7, 0xe6, 0xfe, 0x4f, 0x3a, 0x6, 0x26, 0xc1, 0x21, 0x3, 0x8d, 0x1a, 0x3e, 0xad, 0xdb, 0xea, 0x9c},
@@ -419,7 +418,7 @@ func TestParseGPGKey(t *testing.T) {
419418

420419
// then revoke the key
421420
for _, id := range e.Identities {
422-
id.Revocations = append(id.Revocations, &packet.Signature{RevocationReason: util.ToPointer(packet.KeyCompromised)})
421+
id.Revocations = append(id.Revocations, &packet.Signature{RevocationReason: new(packet.KeyCompromised)})
423422
}
424423
k, err = parseGPGKey(t.Context(), 1, e, true)
425424
require.NoError(t, err)

modules/util/util.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,6 @@ func ToFloat64(number any) (float64, error) {
197197
return value, nil
198198
}
199199

200-
// ToPointer returns the pointer of a copy of any given value
201-
func ToPointer[T any](val T) *T {
202-
return &val
203-
}
204-
205200
// Iif is an "inline-if", it returns "trueVal" if "condition" is true, otherwise "falseVal"
206201
func Iif[T any](condition bool, trueVal, falseVal T) T {
207202
if condition {

modules/util/util_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,6 @@ func TestToTitleCase(t *testing.T) {
212212
assert.Equal(t, `Foo Bar Baz`, ToTitleCase(`FOO BAR BAZ`))
213213
}
214214

215-
func TestToPointer(t *testing.T) {
216-
assert.Equal(t, "abc", *ToPointer("abc"))
217-
assert.Equal(t, 123, *ToPointer(123))
218-
abc := "abc"
219-
assert.NotSame(t, &abc, ToPointer(abc))
220-
val123 := 123
221-
assert.NotSame(t, &val123, ToPointer(val123))
222-
}
223-
224215
func TestReserveLineBreakForTextarea(t *testing.T) {
225216
assert.Equal(t, "test\ndata", ReserveLineBreakForTextarea("test\r\ndata"))
226217
assert.Equal(t, "test\ndata\n", ReserveLineBreakForTextarea("test\r\ndata\r\n"))

modules/web/router_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestRouter(t *testing.T) {
6969
chiCtx := chi.RouteContext(req.Context())
7070
res.method = req.Method
7171
res.pathParams = chiURLParamsToMap(chiCtx)
72-
res.chiRoutePattern = util.ToPointer(chiCtx.RoutePattern())
72+
res.chiRoutePattern = new(chiCtx.RoutePattern())
7373
if mark != "" {
7474
res.handlerMarks = append(res.handlerMarks, mark)
7575
}
@@ -139,7 +139,7 @@ func TestRouter(t *testing.T) {
139139
testRoute(t, "GET /the-user/the-repo/other", resultStruct{
140140
method: "GET",
141141
handlerMarks: []string{"not-found:/"},
142-
chiRoutePattern: util.ToPointer(""),
142+
chiRoutePattern: new(""),
143143
})
144144
testRoute(t, "GET /the-user/the-repo/pulls", resultStruct{
145145
method: "GET",
@@ -150,7 +150,7 @@ func TestRouter(t *testing.T) {
150150
method: "GET",
151151
pathParams: map[string]string{"username": "the-user", "reponame": "the-repo", "type": "issues", "index": "123"},
152152
handlerMarks: []string{"view-issue"},
153-
chiRoutePattern: util.ToPointer("/{username}/{reponame}/{type:issues|pulls}/{index}"),
153+
chiRoutePattern: new("/{username}/{reponame}/{type:issues|pulls}/{index}"),
154154
})
155155
testRoute(t, "GET /the-user/the-repo/issues/123?stop=hijack", resultStruct{
156156
method: "GET",
@@ -228,7 +228,7 @@ func TestRouter(t *testing.T) {
228228
method: "GET",
229229
pathParams: map[string]string{"username": "the-user", "reponame": "the-repo", "*": "d1/d2/fn", "dir": "d1/d2", "file": "fn"},
230230
handlerMarks: []string{"s1", "s2", "s3"},
231-
chiRoutePattern: util.ToPointer("/api/v1/repos/{username}/{reponame}/branches/<dir:*>/<file:[a-z]{1,2}>"),
231+
chiRoutePattern: new("/api/v1/repos/{username}/{reponame}/branches/<dir:*>/<file:[a-z]{1,2}>"),
232232
})
233233
})
234234
}

routers/web/repo/attachment.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"code.gitea.io/gitea/modules/log"
1515
"code.gitea.io/gitea/modules/setting"
1616
"code.gitea.io/gitea/modules/storage"
17-
"code.gitea.io/gitea/modules/util"
1817
"code.gitea.io/gitea/routers/common"
1918
"code.gitea.io/gitea/services/attachment"
2019
"code.gitea.io/gitea/services/context"
@@ -200,7 +199,7 @@ func ServeAttachment(ctx *context.Context, uuid string) {
200199
}
201200
defer fr.Close()
202201

203-
common.ServeContentByReadSeeker(ctx.Base, attach.Name, util.ToPointer(attach.CreatedUnix.AsTime()), fr)
202+
common.ServeContentByReadSeeker(ctx.Base, attach.Name, new(attach.CreatedUnix.AsTime()), fr)
204203
}
205204

206205
// GetAttachment serve attachments

services/migrations/codebase_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ func TestCodebaseDownloadRepo(t *testing.T) {
5454
assertMilestonesEqual(t, []*base.Milestone{
5555
{
5656
Title: "Milestone1",
57-
Deadline: timePtr(time.Date(2021, time.September, 16, 0, 0, 0, 0, time.UTC)),
57+
Deadline: new(time.Date(2021, time.September, 16, 0, 0, 0, 0, time.UTC)),
5858
},
5959
{
6060
Title: "Milestone2",
61-
Deadline: timePtr(time.Date(2021, time.September, 17, 0, 0, 0, 0, time.UTC)),
62-
Closed: timePtr(time.Date(2021, time.September, 17, 0, 0, 0, 0, time.UTC)),
61+
Deadline: new(time.Date(2021, time.September, 17, 0, 0, 0, 0, time.UTC)),
62+
Closed: new(time.Date(2021, time.September, 17, 0, 0, 0, 0, time.UTC)),
6363
State: "closed",
6464
},
6565
}, milestones)

0 commit comments

Comments
 (0)