This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
cd src
go build -ldflags "-X github.com/whywhathow/jenv/cmd.Version=1.0.0" -o jenvFor development builds with debug information:
cd src
go build -o jenvcd src
go test ./...Run specific test:
cd src
go test ./internal/java -vcd src
go mod download
go mod tidy# For tagged releases - handled by GitHub Actions
# Local assembly for testing:
jreleaser assemble- Entry Point:
src/jenv.go- Main entry point that callscmd.Execute() - Commands:
src/cmd/- All CLI commands using Cobra framework - Internal Packages:
src/internal/- Core functionality modules
- Singleton pattern with thread-safe access using sync.RWMutex
- JSON-based configuration stored in user's home directory (
~/.jenv/config.json) - Cross-platform symlink management for Windows/Linux/macOS
- JDK registry using map-based storage for O(1) lookups
- Concurrent JDK scanning using Dispatcher-Worker pattern with goroutines
- Platform-specific path validation (javac.exe on Windows, javac on Unix)
- Ultra-fast scanning optimized from 3s to 300ms through aggressive pre-filtering
- Platform-specific environment variable handling
- Windows: Registry-based environment management
- Linux/Unix: Shell configuration file updates (.bashrc, .zshrc, config.fish)
- Automatic privilege escalation detection and handling
- Administrator privilege detection for Windows (UAC) and Unix (root)
- Platform-specific permission handling with graceful degradation
- Theme system with light/dark mode support
- Consistent styling using Charm's lipgloss library
- Terminal-friendly output formatting
The application uses symbolic links for efficient Java version switching:
- Windows:
C:\java\JAVA_HOMEpoints to active JDK - Linux System:
/opt/jenv/java_home(root) or~/.jenv/java_home(user) - macOS:
/opt/jenv/java_home(root) or~/.jenv/java_home(user)
- Windows: Complete support with administrator privileges required
- Linux: Complete support with optional root privileges
- macOS: Infrastructure ready, implementation in progress
- Singleton configuration with double-checked locking
- Read-write locks for configuration access
- Worker pool pattern for JDK scanning performance
- Thread-safe JDK registry operations
- Custom error types:
ErrJDKExists,ErrJDKNotFound,ErrInvalidPath,ErrNotInitialized - Graceful degradation when admin privileges unavailable on Linux
- Platform-specific error messages and remediation suggestions
- Module:
github.com/whywhathow/jenv - Go version: 1.23.4
- Main dependencies: Cobra CLI, Charm Lipgloss, testify
Version is injected at build time using ldflags:
-ldflags "-X github.com/whywhathow/jenv/cmd.Version=${VERSION}"Tests use standard Go testing with testify assertions. Test files follow *_test.go naming convention.
- Uses JReleaser for cross-platform builds and GitHub releases
- Automated through GitHub Actions on tag push
- Supports multiple architectures: amd64, arm64 for Windows, Linux, macOS