Skip to content

Commit

Permalink
--use flag prints message as per shell
Browse files Browse the repository at this point in the history
  • Loading branch information
Ankit Charolia committed Aug 9, 2023
1 parent b56c3b9 commit fde31fd
Showing 1 changed file with 9 additions and 8 deletions.
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

0 comments on commit fde31fd

Please sign in to comment.