diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 0000000..0c44fcb --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,48 @@ +name: linter + +on: + push: + paths: + - '**.go' + - go.sum + - go.mod + branches-ignore: + - main + pull_request: + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.23.x' + + - name: Deps cache + id: cache-go-deps + uses: actions/cache@v4 + env: + cache-name: go-deps-cache + with: + path: ~/godeps + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + + - if: ${{ steps.cache-go-deps.outputs.cache-hit != 'true' }} + name: List the state of go modules + continue-on-error: true + run: go mod graph + + - name: Install dependencies + run: | + go mod tidy + go mod download + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5 + + - name: Run golangci-lint + run: golangci-lint run + diff --git a/internal/setup/model.go b/internal/setup/model.go index f0461f7..e54dc6c 100644 --- a/internal/setup/model.go +++ b/internal/setup/model.go @@ -132,7 +132,7 @@ After adding to PATH, restart your terminal or run: highlightStyle.Render(m.shimPath), highlightStyle.Render(fmt.Sprintf("echo 'export PATH=\"$HOME/.govm/shim:$PATH\"' >> %s", shellConfigFile)), shellConfigFile, - highlightStyle.Render(fmt.Sprintf("export PATH=\"$HOME/.govm/shim:$PATH\"")), + highlightStyle.Render("export PATH=\"$HOME/.govm/shim:$PATH\""), highlightStyle.Render(fmt.Sprintf("source %s", shellConfigFile))) } diff --git a/internal/utils/utils.go b/internal/utils/utils.go index 81898ec..e55e816 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -259,7 +259,9 @@ func DownloadAndInstall(version GoVersion) tea.Cmd { if runtime.GOOS != "windows" { goBin := filepath.Join(versionDir, "bin", "go") if _, err := os.Stat(goBin); err == nil { - os.Chmod(goBin, 0755) + if err := os.Chmod(goBin, 0755); err != nil { + return ErrMsg(fmt.Errorf("failed to set executable permissions: %v", err)) + } } } goBin := filepath.Join(versionDir, "bin", "go")