-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
informative RED runtime error message when type error detected
- Loading branch information
Showing
2 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package color | ||
|
||
import "runtime" | ||
|
||
const ( | ||
reset = "\033[0m" | ||
red = "\033[31m" | ||
green = "\033[32m" | ||
yellow = "\033[33m" | ||
blue = "\033[34m" | ||
purple = "\033[35m" | ||
cyan = "\033[36m" | ||
gray = "\033[37m" | ||
white = "\033[97m" | ||
) | ||
|
||
var ( | ||
isWindows bool | ||
) | ||
|
||
func init() { | ||
isWindows = runtime.GOOS == "windows" | ||
} | ||
|
||
func Reset() string { | ||
if isWindows { | ||
return "" | ||
} | ||
return reset | ||
} | ||
|
||
func Red() string { | ||
if isWindows { | ||
return "" | ||
} | ||
return red | ||
} | ||
|
||
func Green() string { | ||
if isWindows { | ||
return "" | ||
} | ||
return green | ||
} | ||
|
||
func Yellow() string { | ||
if isWindows { | ||
return "" | ||
} | ||
return yellow | ||
} | ||
|
||
func Blue() string { | ||
if isWindows { | ||
return "" | ||
} | ||
return blue | ||
} | ||
|
||
func Purple() string { | ||
if isWindows { | ||
return "" | ||
} | ||
return purple | ||
} | ||
|
||
func Cyan() string { | ||
if isWindows { | ||
return "" | ||
} | ||
return cyan | ||
} | ||
|
||
func Gray() string { | ||
if isWindows { | ||
return "" | ||
} | ||
return gray | ||
} | ||
|
||
func White() string { | ||
if isWindows { | ||
return "" | ||
} | ||
return white | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters