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
Changes from 1 commit
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
Prev Previous commit
--use flag prints message as per shell
  • Loading branch information
Ankit Charolia committed Aug 9, 2023
commit fde31fdf88030aed8b3eb98cd7e07168bf66009f
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