diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..11f777b --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,24 @@ +name: golangci-lint +on: + push: + branches: + - main + - master + pull_request: + +permissions: + contents: read + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: actions/setup-go@v6 + with: + go-version: stable + - name: golangci-lint + uses: golangci/golangci-lint-action@v8 + with: + version: v2.1 \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..5460e76 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,10 @@ +version: "2" + +run: + tests: false + +linters: + default: standard + exclusions: + paths: + - '(^|/)examples(/|$)' diff --git a/CHANGELOG.md b/CHANGELOG.md index eef6784..c730e39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased +### Added +- Golang CI lint config and workflow + ## [v1.8.2] - 2025-09-20 ### Updated - Expose Option for use in the sub S3 extension diff --git a/examples/intermediate/01-keyboard-controls/main.go b/examples/intermediate/01-keyboard-controls/main.go index da19d7a..ae32318 100644 --- a/examples/intermediate/01-keyboard-controls/main.go +++ b/examples/intermediate/01-keyboard-controls/main.go @@ -5,7 +5,7 @@ import ( "os" "github.com/Digital-Shane/treeview" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbletea" ) func main() { diff --git a/examples/intermediate/02-search/main.go b/examples/intermediate/02-search/main.go index 70113ba..f6a71a2 100644 --- a/examples/intermediate/02-search/main.go +++ b/examples/intermediate/02-search/main.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/Digital-Shane/treeview" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbletea" ) // Product represents a product with additional searchable data diff --git a/examples/intermediate/03-viewport/main.go b/examples/intermediate/03-viewport/main.go index a736547..2f88548 100644 --- a/examples/intermediate/03-viewport/main.go +++ b/examples/intermediate/03-viewport/main.go @@ -5,7 +5,7 @@ import ( "log" "github.com/Digital-Shane/treeview" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbletea" ) func main() { diff --git a/examples/intermediate/04-file-browser/main.go b/examples/intermediate/04-file-browser/main.go index c2511ae..4a6d57e 100644 --- a/examples/intermediate/04-file-browser/main.go +++ b/examples/intermediate/04-file-browser/main.go @@ -11,7 +11,7 @@ import ( "time" "github.com/Digital-Shane/treeview" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" ) diff --git a/tui.go b/tui.go index 3e3274e..07ac2e3 100644 --- a/tui.go +++ b/tui.go @@ -8,7 +8,7 @@ import ( "time" "github.com/charmbracelet/bubbles/viewport" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbletea" ) // TuiTreeModelOption represents a functional Option that configures a TuiTreeModel instance directly. @@ -224,7 +224,7 @@ func (m *TuiTreeModel[T]) handleKeypress(msg tea.KeyMsg) (tea.Model, tea.Cmd) { case slices.Contains(m.keyMap.SearchDelete, key): if len(m.searchTerm) > 0 { m.searchTerm = m.searchTerm[:len(m.searchTerm)-1] - m.Search(m.searchTerm) + _, _ = m.Search(m.searchTerm) } return m, nil @@ -236,7 +236,7 @@ func (m *TuiTreeModel[T]) handleKeypress(msg tea.KeyMsg) (tea.Model, tea.Cmd) { // Add printable characters to search if len(key) == 1 && key >= " " && key <= "~" { m.searchTerm += key - m.Search(m.searchTerm) + _, _ = m.Search(m.searchTerm) return m, nil } } @@ -270,7 +270,7 @@ func (m *TuiTreeModel[T]) handleKeypress(msg tea.KeyMsg) (tea.Model, tea.Cmd) { m.BeginSearch() return m, nil case slices.Contains(m.keyMap.Reset, key): - m.ShowAll(context.Background()) + _ = m.ShowAll(context.Background()) return m, nil } @@ -463,7 +463,7 @@ func (m *TuiTreeModel[T]) updateViewportDimensions() { m.viewport.Height = viewHeight // Update tree truncation width to match viewport width - m.Tree.mu.Lock() - m.Tree.truncateWidth = m.width - m.Tree.mu.Unlock() + m.mu.Lock() + m.truncateWidth = m.width + m.mu.Unlock() } diff --git a/tui_test.go b/tui_test.go index 2e6810a..081ee5c 100644 --- a/tui_test.go +++ b/tui_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - tea "github.com/charmbracelet/bubbletea" + "github.com/charmbracelet/bubbletea" "github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp/cmpopts" )