21 lines
374 B
Go
21 lines
374 B
Go
package utils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
func Debug(v interface{}, args ...string) {
|
|
// utils.Debug(variable)
|
|
debug, err := json.MarshalIndent(v, "", " ")
|
|
if err != nil {
|
|
fmt.Println("Error marshaling JSON:", err)
|
|
return
|
|
}
|
|
// Print a title if there is one
|
|
if len(args) > 0 {
|
|
fmt.Printf("%s\n", args[0])
|
|
}
|
|
fmt.Printf("DEBUG:\n%s\n", string(debug))
|
|
}
|