mirror of
https://github.com/jimeh/undent.git
synced 2026-02-19 11:56:39 +00:00
feat(print) add Print, Printf, Fprint, and Fprintf functions
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package undent_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
|
||||
"github.com/jimeh/undent"
|
||||
@@ -60,3 +61,57 @@ func ExampleStringf() {
|
||||
// "hello": "world"
|
||||
// }
|
||||
}
|
||||
|
||||
func ExamplePrint() {
|
||||
undent.Print(`
|
||||
{
|
||||
"hello": "world"
|
||||
}`,
|
||||
)
|
||||
// Output:
|
||||
// {
|
||||
// "hello": "world"
|
||||
// }
|
||||
}
|
||||
|
||||
func ExamplePrintf() {
|
||||
undent.Printf(`
|
||||
{
|
||||
"hello": "%s"
|
||||
}`,
|
||||
"world",
|
||||
)
|
||||
// Output:
|
||||
// {
|
||||
// "hello": "world"
|
||||
// }
|
||||
}
|
||||
|
||||
func ExampleFprint() {
|
||||
var buf bytes.Buffer
|
||||
undent.Fprint(&buf, `
|
||||
{
|
||||
"hello": "world"
|
||||
}`,
|
||||
)
|
||||
fmt.Println(buf.String())
|
||||
// Output:
|
||||
// {
|
||||
// "hello": "world"
|
||||
// }
|
||||
}
|
||||
|
||||
func ExampleFprintf() {
|
||||
var buf bytes.Buffer
|
||||
undent.Fprintf(&buf, `
|
||||
{
|
||||
"hello": "%s"
|
||||
}`,
|
||||
"world",
|
||||
)
|
||||
fmt.Println(buf.String())
|
||||
// Output:
|
||||
// {
|
||||
// "hello": "world"
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user