From be7583dd40212983c13fc6b26d6c11dfbc4f03bf Mon Sep 17 00:00:00 2001 From: Kevin Radloff Date: Sat, 8 Mar 2025 10:40:10 -0500 Subject: [PATCH] Update to go 1.24 --- .github/workflows/ci.yml | 18 +++++++++--------- .github/workflows/release.yml | 2 +- .golangci.yml | 2 +- Dockerfile | 2 +- go.mod | 2 +- pkg/cheatsheet/generate.go | 10 ++++++---- pkg/commands/git_commands/branch_loader.go | 6 +++--- pkg/commands/git_commands/remote_loader.go | 10 +++++----- .../helpers/window_arrangement_helper_test.go | 14 ++++++-------- pkg/gui/filetree/node.go | 11 ++++++----- pkg/gui/presentation/graph/graph.go | 9 +++++---- 11 files changed, 44 insertions(+), 42 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a991efe49..a108733b3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: Continuous Integration env: - GO_VERSION: 1.22 + GO_VERSION: 1.24 on: push: @@ -32,7 +32,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.24.x - name: Test code # we're passing -short so that we skip the integration tests, which will be run in parallel below run: | @@ -89,7 +89,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.24.x - name: Print git version run: git --version - name: Test code @@ -115,7 +115,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.24.x - name: Build linux binary run: | GOOS=linux go build @@ -142,7 +142,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.24.x - name: Check Vendor Directory # ensure our vendor directory matches up with our go modules run: | @@ -168,11 +168,11 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.24.x - name: Lint - uses: golangci/golangci-lint-action@v6.1.0 + uses: golangci/golangci-lint-action@v6.5.0 with: - version: v1.60 + version: v1.64.6 - name: errors run: golangci-lint run if: ${{ failure() }} @@ -197,7 +197,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.24.x - name: Download all coverage artifacts uses: actions/download-artifact@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1b95f6be7..3c6ef7b56 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -126,7 +126,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.22.x + go-version: 1.24.x - name: Run goreleaser uses: goreleaser/goreleaser-action@v4 diff --git a/.golangci.yml b/.golangci.yml index 9fbf5329e..209e79c5c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -32,5 +32,5 @@ linters-settings: max-func-lines: 0 run: - go: '1.22' + go: "1.24" timeout: 10m diff --git a/Dockerfile b/Dockerfile index 6ddba8414..796787a6d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # docker build -t lazygit . # docker run -it lazygit:latest /bin/sh -FROM golang:1.22 as build +FROM golang:1.24 as build WORKDIR /go/src/github.com/jesseduffield/lazygit/ COPY go.mod go.sum ./ RUN go mod download diff --git a/go.mod b/go.mod index f0f2a20bc..6fb7fb056 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/jesseduffield/lazygit -go 1.22 +go 1.24 require ( github.com/adrg/xdg v0.4.0 diff --git a/pkg/cheatsheet/generate.go b/pkg/cheatsheet/generate.go index 100245f62..812ce0c8f 100644 --- a/pkg/cheatsheet/generate.go +++ b/pkg/cheatsheet/generate.go @@ -11,9 +11,12 @@ package cheatsheet import ( + "cmp" "fmt" "log" "os" + "slices" + "strings" "github.com/jesseduffield/generics/maps" "github.com/jesseduffield/lazycore/pkg/utils" @@ -23,7 +26,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/jesseduffield/lazygit/pkg/i18n" "github.com/samber/lo" - "golang.org/x/exp/slices" ) type bindingSection struct { @@ -164,11 +166,11 @@ func getBindingSections(bindings []*types.Binding, tr *i18n.TranslationSet) []*b }, ) - slices.SortFunc(bindingGroups, func(a, b headerWithBindings) bool { + slices.SortFunc(bindingGroups, func(a, b headerWithBindings) int { if a.header.priority != b.header.priority { - return a.header.priority > b.header.priority + return cmp.Compare(b.header.priority, a.header.priority) } - return a.header.title < b.header.title + return strings.Compare(a.header.title, b.header.title) }) return lo.Map(bindingGroups, func(hb headerWithBindings, _ int) *bindingSection { diff --git a/pkg/commands/git_commands/branch_loader.go b/pkg/commands/git_commands/branch_loader.go index cf36cfe23..606f5c30d 100644 --- a/pkg/commands/git_commands/branch_loader.go +++ b/pkg/commands/git_commands/branch_loader.go @@ -3,6 +3,7 @@ package git_commands import ( "fmt" "regexp" + "slices" "strconv" "strings" "time" @@ -14,7 +15,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" - "golang.org/x/exp/slices" "golang.org/x/sync/errgroup" ) @@ -95,8 +95,8 @@ func (self *BranchLoader) Load(reflogCommits []*models.Commit, // Sort branches that don't have a recency value alphabetically // (we're really doing this for the sake of deterministic behaviour across git versions) - slices.SortFunc(branches, func(a *models.Branch, b *models.Branch) bool { - return a.Name < b.Name + slices.SortFunc(branches, func(a *models.Branch, b *models.Branch) int { + return strings.Compare(a.Name, b.Name) }) branches = utils.Prepend(branches, branchesWithRecency...) diff --git a/pkg/commands/git_commands/remote_loader.go b/pkg/commands/git_commands/remote_loader.go index 9d48374c5..dcf62de97 100644 --- a/pkg/commands/git_commands/remote_loader.go +++ b/pkg/commands/git_commands/remote_loader.go @@ -2,6 +2,7 @@ package git_commands import ( "fmt" + "slices" "strings" "sync" @@ -11,7 +12,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" - "golang.org/x/exp/slices" ) type RemoteLoader struct { @@ -67,15 +67,15 @@ func (self *RemoteLoader) GetRemotes() ([]*models.Remote, error) { }) // now lets sort our remotes by name alphabetically - slices.SortFunc(remotes, func(a, b *models.Remote) bool { + slices.SortFunc(remotes, func(a, b *models.Remote) int { // we want origin at the top because we'll be most likely to want it if a.Name == "origin" { - return true + return -1 } if b.Name == "origin" { - return false + return 1 } - return strings.ToLower(a.Name) < strings.ToLower(b.Name) + return strings.Compare(strings.ToLower(a.Name), strings.ToLower(b.Name)) }) return remotes, nil diff --git a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go index d8a6f739c..6274fae2b 100644 --- a/pkg/gui/controllers/helpers/window_arrangement_helper_test.go +++ b/pkg/gui/controllers/helpers/window_arrangement_helper_test.go @@ -1,7 +1,9 @@ package helpers import ( + "cmp" "fmt" + "slices" "strings" "testing" @@ -9,7 +11,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/config" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" - "golang.org/x/exp/slices" ) // The best way to add test cases here is to set your args and then get the @@ -490,16 +491,13 @@ func renderLayout(windows map[string]boxlayout.Dimensions) string { // Sort first by name, then by position. This means our short labels will // increment in the order that the windows appear on the screen. slices.Sort(windowNames) - slices.SortStableFunc(windowNames, func(a, b string) bool { + slices.SortStableFunc(windowNames, func(a, b string) int { dimensionsA := windows[a] dimensionsB := windows[b] - if dimensionsA.Y0 < dimensionsB.Y0 { - return true + if dimensionsA.Y0 != dimensionsB.Y0 { + return cmp.Compare(dimensionsA.Y0, dimensionsB.Y0) } - if dimensionsA.Y0 > dimensionsB.Y0 { - return false - } - return dimensionsA.X0 < dimensionsB.X0 + return cmp.Compare(dimensionsA.X0, dimensionsB.X0) }) // Uniquify windows by dimensions (so perfectly overlapping windows are de-duped). This prevents getting 'fileshes' as a label where the files and branches windows overlap. diff --git a/pkg/gui/filetree/node.go b/pkg/gui/filetree/node.go index e38a1c5de..dddafde27 100644 --- a/pkg/gui/filetree/node.go +++ b/pkg/gui/filetree/node.go @@ -2,11 +2,12 @@ package filetree import ( "path" + "slices" + "strings" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/types" "github.com/samber/lo" - "golang.org/x/exp/slices" ) // Represents a file or directory in a file tree. @@ -80,15 +81,15 @@ func (self *Node[T]) SortChildren() { children := slices.Clone(self.Children) - slices.SortFunc(children, func(a, b *Node[T]) bool { + slices.SortFunc(children, func(a, b *Node[T]) int { if !a.IsFile() && b.IsFile() { - return true + return -1 } if a.IsFile() && !b.IsFile() { - return false + return 1 } - return a.GetPath() < b.GetPath() + return strings.Compare(a.GetPath(), b.GetPath()) }) // TODO: think about making this in-place diff --git a/pkg/gui/presentation/graph/graph.go b/pkg/gui/presentation/graph/graph.go index 7f3eb8a27..441c91301 100644 --- a/pkg/gui/presentation/graph/graph.go +++ b/pkg/gui/presentation/graph/graph.go @@ -1,7 +1,9 @@ package graph import ( + "cmp" "runtime" + "slices" "strings" "sync" @@ -10,7 +12,6 @@ import ( "github.com/jesseduffield/lazygit/pkg/gui/style" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" - "golang.org/x/exp/slices" ) type PipeKind uint8 @@ -269,11 +270,11 @@ func getNextPipes(prevPipes []*Pipe, commit *models.Commit, getStyle func(c *mod } // not efficient but doing it for now: sorting my pipes by toPos, then by kind - slices.SortFunc(newPipes, func(a, b *Pipe) bool { + slices.SortFunc(newPipes, func(a, b *Pipe) int { if a.toPos == b.toPos { - return a.kind < b.kind + return cmp.Compare(a.kind, b.kind) } - return a.toPos < b.toPos + return cmp.Compare(a.toPos, b.toPos) }) return newPipes