Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/fix bugs #9

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ goenv is a command-line tool to manage multiple versions of Golang on your syste
## Installation
**Download**: https://github.com/ankitcharolia/goenv/releases
```shell
wget -O - https://github.com/ankitcharolia/goenv/releases/download/<VERSION>/goenv-linux-amd64.tar.gz | tar -xz -C ~/.go
wget -O - https://github.com/ankitcharolia/goenv/releases/latest/download/goenv-linux-amd64.tar.gz | tar -xz -C ~/.go
export PATH=$HOME/.go:$PATH >> ~/.bashrc
source ~/.bashrc
```
Expand Down
17 changes: 9 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,21 +326,22 @@ func useGoVersion(version string) {
newPath := fmt.Sprintf("%s%c$PATH", binPath, os.PathListSeparator)
os.Setenv("PATH", newPath)

// ANSI escape code for red color
redColor := "\033[31m"
// ANSI escape code to reset color to default
resetColor := "\033[0m"

// Update the Go version in the appropriate shell configuration file
shell := getShell()
if shell == "bash" {
updateGoVersionInShellRC(version, ".bashrc")
message := fmt.Sprintf("Using Go version %s.%s\nPlease make sure to execute: source ~/.bashrc\n%s", version, redColor, resetColor)
fmt.Print(message)
} else if shell == "zsh" {
updateGoVersionInShellRC(version, ".zshrc")
message := fmt.Sprintf("Using Go version %s.%s\nPlease make sure to execute: source ~/.zshrc\n%s", version, redColor, resetColor)
fmt.Print(message)
}

// ANSI escape code for red color
redColor := "\033[31m"
// ANSI escape code to reset color to default
resetColor := "\033[0m"

message := fmt.Sprintf("Using Go version %s.%s\nPlease make sure to execute: source ~/.bashrc\n%s", version, redColor, resetColor)
fmt.Print(message)
}

// getShell returns the user's default shell
Expand Down