diff --git a/Makefile b/Makefile index e286677d71d..77b9cc96825 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ SHASUM ?= shasum -a 256 AIR_PACKAGE ?= github.com/air-verse/air@v1.67.4 # renovate: datasource=go EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v4/cmd/editorconfig-checker@v4.0.2 # renovate: datasource=go -GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2 # renovate: datasource=go +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.14.0 # renovate: datasource=go GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.17 # renovate: datasource=go MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.8.0 # renovate: datasource=go SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.36.6 # renovate: datasource=go diff --git a/go.mod b/go.mod index 9c474172478..b4b2ce6510d 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module gitea.dev go 1.27 -toolchain go1.27.1 +toolchain go1.27.2 require ( connectrpc.com/connect v1.21.0 diff --git a/modules/assetfs/embed.go b/modules/assetfs/embed.go index 99a6e5e6242..28d0fc25f03 100644 --- a/modules/assetfs/embed.go +++ b/modules/assetfs/embed.go @@ -102,11 +102,11 @@ func NewEmbeddedFS(data []byte) fs.ReadDirFS { efs := &embeddedFS{data: data, files: make(map[string]*embeddedFileInfo)} efs.meta = sync.OnceValue(func() *EmbeddedMeta { var meta EmbeddedMeta - p := bytes.LastIndexByte(data, '\n') - if p < 0 { + _, metaJSON, ok := bytes.CutLast(data, []byte{'\n'}) + if !ok { return &meta } - if err := json.Unmarshal(data[p+1:], &meta); err != nil { + if err := json.Unmarshal(metaJSON, &meta); err != nil { panic("embedded file is not valid") } return &meta diff --git a/modules/web/routing/funcinfo.go b/modules/web/routing/funcinfo.go index 8a94711c323..7776c975b24 100644 --- a/modules/web/routing/funcinfo.go +++ b/modules/web/routing/funcinfo.go @@ -135,8 +135,8 @@ func shortenFilename(filename, fallback string) string { if filename == "" { return fallback } - if lastIndex := strings.LastIndexByte(filename, '/'); lastIndex >= 0 { - if secondLastIndex := strings.LastIndexByte(filename[:lastIndex], '/'); secondLastIndex >= 0 { + if dir, _, ok := strings.CutLast(filename, "/"); ok { + if secondLastIndex := strings.LastIndexByte(dir, '/'); secondLastIndex >= 0 { return filename[secondLastIndex+1:] } }