add models generation and josn print
This commit is contained in:
23
app/utils/jsonprint/jsonprint.go
Normal file
23
app/utils/jsonprint/jsonprint.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package jsonprint
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/alecthomas/chroma/quick"
|
||||
)
|
||||
|
||||
func Print(v any) {
|
||||
// Marshal your data to pretty JSON
|
||||
b, err := json.MarshalIndent(v, "", " ")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Use Chroma to print colored JSON to stdout
|
||||
// lexer: "json", style: "monokai", writer: os.Stdout
|
||||
err = quick.Highlight(os.Stdout, string(b), "json", "terminal", "solarized")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user