@@ -13,15 +13,23 @@ const colorYellow string = "\033[33m"
1313const colorLightBlue string = "\033 [36m"
1414
1515func color (color , msg string ) string {
16- return fmt .Sprintf ("%s%s%s" , color , msg , colorReset )
16+ return color + msg + colorReset
17+ }
18+
19+ func colorPrintln (colorFunc func (string ) string , msgs ... string ) {
20+ colorized := make ([]string , len (msgs ))
21+ for i , msg := range msgs {
22+ colorized [i ] = colorFunc (msg )
23+ }
24+ fmt .Println (strings .Join (colorized , " " ))
1725}
1826
1927func Red (msg string ) string {
2028 return color (colorRed , msg )
2129}
2230
2331func RedPrintln (msgs ... string ) {
24- fmt . Println (Red ( strings . Join ( msgs , " " )) )
32+ colorPrintln (Red , msgs ... )
2533}
2634
2735func RedPrintf (format string , a ... any ) {
@@ -37,7 +45,7 @@ func Green(msg string) string {
3745}
3846
3947func GreenPrintln (msgs ... string ) {
40- fmt . Println (Green ( strings . Join ( msgs , " " )) )
48+ colorPrintln (Green , msgs ... )
4149}
4250
4351func GreenPrintf (format string , a ... any ) {
@@ -53,7 +61,7 @@ func Yellow(msg string) string {
5361}
5462
5563func YellowPrintln (msgs ... string ) {
56- fmt . Println (Yellow ( strings . Join ( msgs , " " )) )
64+ colorPrintln (Yellow , msgs ... )
5765}
5866
5967func YellowPrintf (format string , a ... any ) {
@@ -69,7 +77,7 @@ func LightBlue(msg string) string {
6977}
7078
7179func LightBluePrintln (msgs ... string ) {
72- fmt . Println (LightBlue ( strings . Join ( msgs , " " )) )
80+ colorPrintln (LightBlue , msgs ... )
7381}
7482
7583func LightBluePrintf (format string , a ... any ) {
@@ -85,7 +93,7 @@ func Bold(msg string) string {
8593}
8694
8795func BoldPrintln (msgs ... string ) {
88- fmt . Println (Bold ( strings . Join ( msgs , " " )) )
96+ colorPrintln (Bold , msgs ... )
8997}
9098
9199func BoldPrintf (format string , a ... any ) {
0 commit comments