debug.go
 1  package util
 2  
 3  import (
 4  	"fmt"
 5  
 6  	"github.com/kr/pretty"
 7  )
 8  
 9  // FormatToGoObject formats the given object to equivalent Go code.
10  func FormatToGoObject(object any) string {
11  	return fmt.Sprintf("%# v", pretty.Formatter(object))
12  }
13  
14  // PrettyPrint pretty prints the given object to STDOUT.
15  func PrettyPrint(object any) {
16  	fmt.Printf("- %s\n", FormatToGoObject(object))
17  }
18  
19  // Pretty pretty prints the given object to a string.
20  func Pretty(object any) string {
21  	return FormatToGoObject(object)
22  }