[ Cmii ] [ Octopus ] - 优化项目结构
This commit is contained in:
49
agent-common/utils/PrintUtils.go
Normal file
49
agent-common/utils/PrintUtils.go
Normal file
@@ -0,0 +1,49 @@
|
||||
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 BeautifulPrintListWithTitle(contend []string, title string) {
|
||||
|
||||
fmt.Println()
|
||||
fmt.Println(fmt.Sprintf("content tile is => %s", title))
|
||||
for _, line := range contend {
|
||||
bytes, _ := json.MarshalIndent(line, "", " ")
|
||||
fmt.Println(string(bytes))
|
||||
}
|
||||
fmt.Println("---------- end -----------")
|
||||
}
|
||||
|
||||
func SplitLinePrint() {
|
||||
fmt.Println()
|
||||
fmt.Println()
|
||||
fmt.Println()
|
||||
}
|
||||
Reference in New Issue
Block a user