refactor: refactoring of code to meet all golangci-lint requirements

This commit is contained in:
Jonas Kaninda
2024-11-19 02:54:31 +01:00
parent d97a0aafea
commit 63101ae84f
20 changed files with 413 additions and 313 deletions

View File

@@ -1,62 +0,0 @@
// Package utils /
/*****
@author Jonas Kaninda
@license MIT License <https://opensource.org/licenses/MIT>
@Copyright © 2024 Jonas Kaninda
**/
package utils
import (
"fmt"
"log"
"os"
)
// Info message
func Info(msg string, args ...any) {
log.SetOutput(os.Stdout)
formattedMessage := fmt.Sprintf(msg, args...)
if len(args) == 0 {
log.Printf("INFO: %s\n", msg)
} else {
log.Printf("INFO: %s\n", formattedMessage)
}
}
// Warn a Warning message
func Warn(msg string, args ...any) {
log.SetOutput(os.Stdout)
formattedMessage := fmt.Sprintf(msg, args...)
if len(args) == 0 {
log.Printf("WARN: %s\n", msg)
} else {
log.Printf("WARN: %s\n", formattedMessage)
}
}
// Error error message
func Error(msg string, args ...any) {
log.SetOutput(os.Stdout)
formattedMessage := fmt.Sprintf(msg, args...)
if len(args) == 0 {
log.Printf("ERROR: %s\n", msg)
} else {
log.Printf("ERROR: %s\n", formattedMessage)
}
}
func Fatal(msg string, args ...any) {
log.SetOutput(os.Stdout)
// Fatal logs an error message and exits the program.
formattedMessage := fmt.Sprintf(msg, args...)
if len(args) == 0 {
log.Printf("ERROR: %s\n", msg)
NotifyError(msg)
} else {
log.Printf("ERROR: %s\n", formattedMessage)
NotifyError(formattedMessage)
}
os.Exit(1)
}