Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v2)!: update to go 1.22 #724

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
go-version: [~1.18, ^1]
go-version: [~1.22, ^1]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
coverage:
strategy:
matrix:
go-version: [^1.18]
go-version: [^1.22]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
env:
Expand Down
7 changes: 0 additions & 7 deletions filepicker/filepicker.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
}
}

func (m *Model) pushView(selected, min, max int) {

Check failure on line 185 in filepicker/filepicker.go

View workflow job for this annotation

GitHub Actions / lint / lint (ubuntu-latest)

redefines-builtin-id: redefinition of the built-in function min (revive)

Check failure on line 185 in filepicker/filepicker.go

View workflow job for this annotation

GitHub Actions / lint / lint (ubuntu-latest)

redefines-builtin-id: redefinition of the built-in function min (revive)
m.selectedStack.Push(selected)
m.minStack.Push(min)
m.maxStack.Push(max)
Expand Down Expand Up @@ -511,10 +511,3 @@
}
return false
}

func max(a, b int) int {
if a > b {
return a
}
return b
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/charmbracelet/bubbles/v2

go 1.18
go 1.22

require (
github.com/MakeNowJust/heredoc v1.0.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymanbagabas/go-udiff v0.2.0 h1:TK0fH4MteXUDspT88n8CKzvK0X9O2xu9yQjWpi6yML8=
github.com/aymanbagabas/go-udiff v0.2.0/go.mod h1:RE4Ex0qsGkTAJoQdQQCA0uG+nAzJO/pI/QwceO5fgrA=
github.com/charmbracelet/bubbletea/v2 v2.0.0-alpha.2.0.20250203222705-2e91ec2235cd h1:u+kqgSbIL4pnP7huv4kaYUCmuN2L4yyDvdH81QJ4FZ0=
Expand Down Expand Up @@ -32,11 +33,13 @@ github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/termenv v0.15.2 h1:GohcuySI0QmI3wN8Ok9PtKGkgkFIk7y6Vpb5PvrY+Wo=
github.com/muesli/termenv v0.15.2/go.mod h1:Epx+iuz8sNs7mNKhxzH4fWXGNpZwUaJKRS1noLXviQ8=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand All @@ -45,6 +48,7 @@ github.com/sahilm/fuzzy v0.1.1/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
Expand Down
7 changes: 0 additions & 7 deletions list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -1323,10 +1323,3 @@ func countEnabledBindings(groups [][]key.Binding) (agg int) {
}
return agg
}

func max(a, b int) int {
if a > b {
return a
}
return b
}
4 changes: 2 additions & 2 deletions list/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"io"
"reflect"
"slices"
"strings"
"testing"

Expand Down Expand Up @@ -82,8 +83,7 @@ func TestSetFilterText(t *testing.T) {

list.SetFilterState(Unfiltered)
expected := tc
// TODO: replace with slices.Equal() when project move to go1.18 or later
if !reflect.DeepEqual(list.VisibleItems(), expected) {
if !slices.Equal(list.VisibleItems(), expected) {
t.Fatalf("Error: expected view to contain only %s", expected)
}

Expand Down
7 changes: 0 additions & 7 deletions paginator/paginator.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,3 @@ func (m Model) dotsView() string {
func (m Model) arabicView() string {
return fmt.Sprintf(m.ArabicFormat, m.Page+1, m.TotalPages)
}

func min(a, b int) int {
if a < b {
return a
}
return b
}
14 changes: 0 additions & 14 deletions progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,22 +345,8 @@ func (m *Model) setRamp(colorA, colorB string, scaled bool) {
m.rampColorB = b
}

func max(a, b int) int {
if a > b {
return a
}
return b
}

// IsAnimating returns false if the progress bar reached equilibrium and is no longer animating.
func (m *Model) IsAnimating() bool {
dist := math.Abs(m.percentShown - m.targetPercent)
return !(dist < 0.001 && m.velocity < 0.01)
}

func min(a, b int) int {
if a < b {
return a
}
return b
}
16 changes: 0 additions & 16 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,22 +437,6 @@ func (m *Model) renderRow(r int) string {
return row
}

func max(a, b int) int {
if a > b {
return a
}

return b
}

func min(a, b int) int {
if a < b {
return a
}

return b
}

func clamp(v, low, high int) int {
return min(max(v, low), high)
}
14 changes: 0 additions & 14 deletions textarea/textarea.go
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,8 @@
// repositionView repositions the view of the viewport based on the defined
// scrolling behavior.
func (m *Model) repositionView() {
min := m.viewport.YOffset

Check failure on line 951 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint (ubuntu-latest)

redefines-builtin-id: redefinition of the built-in function min (revive)

Check failure on line 951 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint (ubuntu-latest)

redefines-builtin-id: redefinition of the built-in function min (revive)
max := min + m.viewport.Height() - 1

Check failure on line 952 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint (ubuntu-latest)

redefines-builtin-id: redefinition of the built-in function max (revive)

Check failure on line 952 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint (ubuntu-latest)

redefines-builtin-id: redefinition of the built-in function max (revive)

if row := m.cursorLineNumber(); row < min {
m.viewport.LineUp(min - row)
Expand Down Expand Up @@ -1224,7 +1224,7 @@
displayLine++

var ln string
if m.ShowLineNumbers { //nolint:nestif

Check failure on line 1227 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

directive `//nolint:nestif` is unused for linter "nestif" (nolintlint)

Check failure on line 1227 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (ubuntu-latest)

directive `//nolint:nestif` is unused for linter "nestif" (nolintlint)

Check failure on line 1227 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

directive `//nolint:nestif` is unused for linter "nestif" (nolintlint)

Check failure on line 1227 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (windows-latest)

directive `//nolint:nestif` is unused for linter "nestif" (nolintlint)

Check failure on line 1227 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

directive `//nolint:nestif` is unused for linter "nestif" (nolintlint)

Check failure on line 1227 in textarea/textarea.go

View workflow job for this annotation

GitHub Actions / lint / lint-soft (macos-latest)

directive `//nolint:nestif` is unused for linter "nestif" (nolintlint)
if wl == 0 { // normal line
isCursorLine := m.row == l
s.WriteString(m.lineNumberView(l+1, isCursorLine))
Expand Down Expand Up @@ -1645,20 +1645,6 @@
return min(high, max(low, v))
}

func min(a, b int) int {
if a < b {
return a
}
return b
}

func max(a, b int) int {
if a > b {
return a
}
return b
}

func abs(n int) int {
if n < 0 {
return -n
Expand Down
14 changes: 0 additions & 14 deletions textinput/textinput.go
Original file line number Diff line number Diff line change
Expand Up @@ -761,20 +761,6 @@ func clamp(v, low, high int) int {
return min(high, max(low, v))
}

func min(a, b int) int {
if a < b {
return a
}
return b
}

func max(a, b int) int {
if a > b {
return a
}
return b
}

func (m Model) completionView(offset int) string {
var (
value = m.value
Expand Down
23 changes: 3 additions & 20 deletions viewport/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -687,27 +687,10 @@ func clamp(v, low, high int) int {
return min(high, max(low, v))
}

func min(a, b int) int {
if a < b {
return a
}
return b
}

func max(a, b int) int {
if a > b {
return a
}
return b
}

func maxLineWidth(lines []string) int {
maxlen := 0
result := 0
for _, line := range lines {
llen := ansi.StringWidth(line)
if llen > maxlen {
maxlen = llen
}
result = max(result, ansi.StringWidth(line))
}
return maxlen
return result
}
Loading