From 17a5d4cb6c0c45bc72845251027c80067f321889 Mon Sep 17 00:00:00 2001 From: Ankit Charolia Date: Wed, 9 Aug 2023 20:55:54 +0200 Subject: [PATCH] --use flag prints message as per shell --- main.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 15e095d..90b9d65 100755 --- a/main.go +++ b/main.go @@ -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