-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66204bb
commit 7c42609
Showing
4 changed files
with
72 additions
and
54 deletions.
There are no files selected for viewing
Binary file not shown.
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
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,18 @@ | ||
package helper | ||
|
||
import ( | ||
"fmt" | ||
"gofuzzyclone/lib/logger" | ||
) | ||
|
||
// HandleError is a helper function to handle error | ||
func HandleError(e error, msg ...string) { | ||
if e != nil { | ||
if len(msg) > 0 { | ||
logger.Println("red", msg[0]) | ||
} else { | ||
fmt.Println(e) | ||
} | ||
panic(e) | ||
} | ||
} |
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,32 @@ | ||
package logger | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
// Println prints a message with a color with \n | ||
func Println(color string, message string) { | ||
color = strings.ToLower(color) | ||
var color_palettes = map[string]string{ | ||
"red": "\033[31m", | ||
"green": "\033[32m", | ||
"yellow": "\033[33m", | ||
"reset": "\033[0m", | ||
} | ||
|
||
fmt.Printf("%s%s%s\n", string(color_palettes[color]), message, color_palettes["reset"]) | ||
} | ||
|
||
// Printf prints a message with a color | ||
func Printf(color string, message string) { | ||
color = strings.ToLower(color) | ||
var color_palettes = map[string]string{ | ||
"red": "\033[31m", | ||
"green": "\033[32m", | ||
"yellow": "\033[33m", | ||
"reset": "\033[0m", | ||
} | ||
|
||
fmt.Printf("%s%s%s", string(color_palettes[color]), message, color_palettes["reset"]) | ||
} |