58 lines
1.1 KiB
Go
Executable File
58 lines
1.1 KiB
Go
Executable File
package utils
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"wdd.io/agent-common/logger"
|
|
)
|
|
|
|
var log = logger.Log
|
|
|
|
func BeautifulPrint(object interface{}) {
|
|
|
|
bytes, err := json.MarshalIndent(object, "", " ")
|
|
if err != nil {
|
|
log.ErrorF("[BeautifulPrint] - json marshal error ! => %v", object)
|
|
}
|
|
|
|
fmt.Println()
|
|
fmt.Println(string(bytes))
|
|
fmt.Println()
|
|
|
|
}
|
|
|
|
func BeautifulPrintToString(object interface{}) string {
|
|
|
|
bytes, err := json.MarshalIndent(object, "", " ")
|
|
if err != nil {
|
|
log.ErrorF("[BeautifulPrint] - json marshal error ! => %v", object)
|
|
}
|
|
|
|
return string(bytes)
|
|
}
|
|
|
|
func BeautifulPrintWithTitle(contend any, title string) {
|
|
|
|
fmt.Println()
|
|
fmt.Println(fmt.Sprintf("content tile is => %s", title))
|
|
bytes, _ := json.MarshalIndent(contend, "", " ")
|
|
fmt.Println(string(bytes))
|
|
fmt.Println("---------- end -----------")
|
|
}
|
|
|
|
func BeautifulPrintListWithTitle(contend []string, title string) {
|
|
|
|
fmt.Println()
|
|
fmt.Println(fmt.Sprintf("content tile is => %s", title))
|
|
for _, line := range contend {
|
|
fmt.Println(line)
|
|
}
|
|
fmt.Println("---------- end -----------")
|
|
}
|
|
|
|
func SplitLinePrint() {
|
|
fmt.Println()
|
|
fmt.Println()
|
|
fmt.Println()
|
|
}
|