Tags: go-nv/goenv
Tags
fix: prevent false positive recursion detection in tests (Fixes #564) (… …#569) Problem: When building goenv AUR package with goenv-installed Go (not system Go), all exec tests fail with 'infinite recursion detected' error. This happens because _GOENV_EXEC_ACTIVE=1 is inherited from parent shell when tests run under goenv-managed Go. Root Cause: Simple boolean check (if env var != '') creates false positive when tests inherit _GOENV_EXEC_ACTIVE from parent shell. Pattern: User has goenv Go active → runs 'paru -S goenv' → build runs 'make check' → 'go test' calls goenv exec internally → recursion guard finds inherited env var → FALSE POSITIVE. Solution: Changed recursion guard from simple boolean check to PID-based detection. Now checks if env var value equals parent PID (os.Getppid()), indicating actual shim → exec → shim → exec recursion chain, not just inherited environment. Also added os.Unsetenv('_GOENV_EXEC_ACTIVE') in test setup as defensive measure. Testing: All exec tests now pass (TestExecCommand with 9 subtests, TestExecEnvironmentVariables, TestExecWithShims). PID-based approach prevents false positives while still catching real infinite recursion.
fix(shims): Preserve system PATH case on Windows in goenv exec (#561) * fix(shims): Preserve system PATH case on Windows in goenv exec (#557) Windows environment variables are case-insensitive but os.Environ() preserves the original casing (e.g., Path, PATH, path). Previously, setEnvVar() and prependToPath() used case-sensitive string matching, causing duplicate environment variables when the casing didn't match exactly. This caused PATH to be overwritten instead of prepended, breaking CGO builds when gcc was in the system PATH but not found after goenv exec. Changes: - Added findEnvVar() helper that uses case-insensitive matching on Windows - Updated setEnvVar() to use findEnvVar and preserve original casing - Updated prependToPath() to use findEnvVar and preserve original casing - Added comprehensive unit tests including regression test for issue #557 Fixes #557 * [AB#557] docs: Add optional cross-platform testing with nektos/act Added instructions for developers who want to run cross-platform CI tests locally using nektos/act before pushing to GitHub. Also fixed PATH separator detection in prependToPath() to handle cross- platform test scenarios where Unix-style paths (with :) are tested on Windows runners (which default to ; separator). Changes: - Added nektos/act installation and usage guide to agent instructions - Updated when-to-use guidance to cover all OS-specific code, not just shims - Fixed prependToPath() to detect separator from existing PATH value - Updated repo memory with cross-platform testing guidance This is optional - CI always runs full cross-platform tests automatically. * [AB#557] style: Apply automated formatting - Format markdown sections with proper spacing - Align test struct fields - Clean up whitespace in exec.go * fix(test): Use count check for colon separator detection Fixed Windows test failures where drive letter colons (C:) were being incorrectly detected as path separators. Changed separator detection from: - strings.Contains(currentPath, ":") to: - strings.Count(currentPath, ":") > 1 This distinguishes between: - Drive letters: C:\Windows\System32 (one colon) - Path separators: /usr/bin:/usr/local/bin (multiple colons) Fixes test failures: - TestPrependToPath/prepend_to_existing_path_-_Windows_(lowercase) - TestPrependToPath/prepend_to_existing_PaTh_-_Windows_(mixed_case) * fix(shims): improve separator detection to handle single-colon Unix paths Previous logic failed when Unix paths had exactly 1 colon (e.g., /usr/bin:/bin) because the check was 'count > 1'. This caused Windows CI tests to incorrectly use semicolon as separator when testing Unix-style paths. New logic: - Checks for semicolons first (Windows-style) - Counts colons but excludes drive letter colons (position 1) - Any remaining colons indicate Unix-style separator - Falls back to OS default separator if neither detected Fixes Windows CI test failure for 'prepend to existing PATH - Unix' case. Issue #557
feat: VSCode tools auto-install + go.mod version handling improvements ( #554) * [AB#542] Fix goenv vscode init Currently goenv vscode init added a random json flag, and that's not correct. Clean up and remove the line from the JSON. * feat: Add VSCode Go extension tools installation support Add comprehensive VSCode tools management with automatic installation support for all 8 required tools from the VSCode Go extension. New Features: - Add 'goenv tools install-vscode <version>' command to install all VSCode Go extension tools (gopls, dlv, vscgo, goplay, gomodifytags, impl, gotests, staticcheck) - Add --install-tools flag to 'goenv vscode init' command - Add --install-tools flag to 'goenv vscode setup' command Bug Fixes: - Fix vscgo package path to github.com/golang/vscode-go/vscgo - Fix goplay package path to github.com/haya14busa/goplay/cmd/goplay - Update documentation examples to use 'default-tools' instead of 'default' - Fix test assertion to match new command name Implementation Details: - Add VSCodeTools list with all 8 required tools - Add BuildVSCodeToolsConfig() helper for DRY configuration building - Add InstallVSCodeToolsForVersion() shared installation logic - Integrate tools installation into vscode init and setup workflows Closes #542 * test: Add comprehensive tests for go.mod forward compatibility Add test coverage for GetCurrentVersionResolved() with go.mod scenarios, particularly for Go 1.26+ behavior where 'go mod init' defaults to (N-1).0. Version selection strategy when go.mod is the version source: • Lowest minor version that satisfies the constraint (most conservative) • Highest patch of that minor (always want bug/security fixes) Test scenarios include: - PRIMARY: go.mod 1.25 + installed [1.25.4, 1.26.1, 1.27.0] → uses 1.25.4 (validates lowest satisfying minor, highest patch strategy) - Forward compatibility: go.mod 1.25 with only newer minors (1.26+) → uses minimum compatible (e.g., 1.26.0 over 1.27.0) - Highest patch preference: multiple patches of target minor available → always selects highest patch (e.g., 1.25.4 over 1.25.2) - Backward incompatibility: go.mod 1.26 with only older versions → errors correctly (can't use older version) - Edge cases: no versions installed, full version specs This validates the existing forward compatibility logic in GetCurrentVersionResolved() and findCompatibleVersion() that allows users with go.mod requiring Go 1.25 to successfully use Go 1.26+ while preferring exact minor matches when available. Related to issue #542 (go.mod version handling) * fix: Make cache timing tests more robust for Windows CI Increase TTL and sleep durations in TestCacheGetStats and TestCachePrune to account for Windows timing precision and slower CI environments. Before: - TestCacheGetStats: 100ms TTL with 50ms + 60ms sleeps - TestCachePrune: 50ms TTL with 60ms sleep After: - TestCacheGetStats: 200ms TTL with 50ms + 160ms sleeps - TestCachePrune: 100ms TTL with 120ms sleep This provides more margin for test execution overhead while maintaining the same test logic and coverage.
Remove stale goenv shims from v2 installations during upgrade to v3 (#… …537) * Remove stale goenv shims from v2 installations during upgrade to v3 * Apply suggestions from code review Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * consolidate duplicated logic into helper funcs and add tests * fix windows test failure --------- Co-authored-by: Stathi C. <efstathiosc@gmail.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Efstathios Chouliaris <Efstathios.Chouliaris@thomsonreuters.com>
Bump goreleaser/goreleaser-action from 6 to 7 (#526) Bumps [goreleaser/goreleaser-action](https://github.com/goreleaser/goreleaser-action) from 6 to 7. - [Release notes](https://github.com/goreleaser/goreleaser-action/releases) - [Commits](goreleaser/goreleaser-action@v6...v7) --- updated-dependencies: - dependency-name: goreleaser/goreleaser-action dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
PreviousNext