-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Problem
The current Go-related configuration in our dotfiles is scattered across multiple files, making it harder to maintain and understand. Additionally, we're missing a .zshenv
file for proper environment variable setup.
Current Issues:
-
Scattered Go configuration: Go environment setup is split between:
macos/config/.exports
(lines 5-7):GOENV_ROOT
andPATH
setupmacos/config/.zshrc
(lines 93-98):goenv init
and additionalGOROOT
/GOPATH
setup
-
Missing
.zshenv
file: We don't have a.zshenv
file, which is the proper place for environment variables that should be available to all shell sessions (interactive and non-interactive). -
Incomplete Rust/Cargo setup: While we have
rust-analyzer
installed via Homebrew, we're missing proper Cargo environment sourcing.
Proposed Solution
1. Create .zshenv
file
Create macos/config/.zshenv
to handle environment variables that should be available globally:
- Move
GOENV_ROOT
and goenvPATH
setup from.exports
- Add Cargo environment sourcing (
source "$HOME/.cargo/env"
) - Include other essential environment variables that should be available to all shells
2. Clean up existing files
.exports
: Remove Go-specific environment variables (lines 5-7).zshrc
: Keep only thegoenv init
execution, remove redundantPATH
exportsinstall.sh
: Add.zshenv
to the list of files to be symlinked/copied
3. Improve Go packages script
- Update
macos/scripts/go-packages.sh
to use latest Go version - Add commonly used Go packages to install by default
Benefits
- Better organization: Environment variables in
.zshenv
, initialization hooks in.zshrc
- Proper shell hierarchy:
.zshenv
is sourced for all zsh invocations,.zshrc
only for interactive shells - Rust/Cargo support: Proper Cargo environment setup for Rust development
- Maintainability: Clearer separation of concerns
Implementation Checklist
- Create
macos/config/.zshenv
with:- GOENV_ROOT and goenv PATH setup (moved from
.exports
) - Cargo environment sourcing
- Other essential environment variables
- GOENV_ROOT and goenv PATH setup (moved from
- Update
macos/config/.exports
:- Remove Go-related environment variables (lines 5-7)
- Update
macos/config/.zshrc
:- Clean up goenv setup (remove redundant PATH exports)
- Keep only
goenv init
execution
- Update
macos/install.sh
:- Add
.zshenv
to files list for symlinking/copying
- Add
- Update
macos/scripts/go-packages.sh
:- Update to latest Go version
- Consider adding default Go packages
Files to be Modified
macos/config/.zshenv
(new file)macos/config/.exports
macos/config/.zshrc
macos/install.sh
macos/scripts/go-packages.sh
Additional Context
This cleanup aligns with shell best practices where:
.zshenv
contains environment variables for all shells.zshrc
contains interactive shell configuration- Version managers (like goenv) are initialized in interactive shells but their PATH setup happens at the environment level
The same .zshenv
approach can be extended for other language environments like Python (pyenv), Node (nodenv), etc.