mirror of
https://github.com/jimeh/go-render.git
synced 2026-02-19 11:26:39 +00:00
refactor: focus around Render/Compact/Pretty/NewWith functions
This is yet another drastic refactor of public API and concepts. Hopefully the last one, as I'm now fairly happy with things.
This commit is contained in:
@@ -39,10 +39,7 @@ func ExampleRender_json() {
|
||||
buf := &bytes.Buffer{}
|
||||
err := render.Pretty(buf, "json", data)
|
||||
if err != nil {
|
||||
fmt.Printf("err: %s\n", err)
|
||||
|
||||
return
|
||||
// panic(err)
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(buf.String())
|
||||
|
||||
@@ -142,13 +139,13 @@ func ExampleRender_xml() {
|
||||
Tags: []string{"golang", "json", "yaml", "toml"},
|
||||
}
|
||||
|
||||
// Create a new renderer that supports XML in addition to default JSON, YAML
|
||||
// and Text.
|
||||
r, _ := render.NewPretty("json", "text", "xml", "yaml")
|
||||
// Create a new renderer that supports XML in addition to the default JSON,
|
||||
// Text, and YAML formats.
|
||||
renderer := render.NewWith("json", "text", "xml", "yaml")
|
||||
|
||||
// Render the object to XML.
|
||||
buf := &bytes.Buffer{}
|
||||
err := r.Render(buf, "xml", data)
|
||||
err := renderer.Pretty(buf, "xml", data)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user