feat(undent): add initial implementation of String, Stringf, and Bytes

This commit is contained in:
2020-11-26 02:48:17 +00:00
parent 7228fc7247
commit 6cdaf8a476
10 changed files with 812 additions and 0 deletions

51
undent_example_test.go Normal file
View File

@@ -0,0 +1,51 @@
package undent_test
import (
"fmt"
"github.com/jimeh/undent"
)
func ExampleBytes() {
b := undent.Bytes([]byte(`
{
"hello": "world"
}`,
))
fmt.Println(string(b))
// Output:
//
// {
// "hello": "world"
// }
}
func ExampleString() {
s := undent.String(`
{
"hello": "world"
}`,
)
fmt.Println(s)
// Output:
//
// {
// "hello": "world"
// }
}
func ExampleStringf() {
s := undent.Stringf(`
{
"hello": "%s"
}`,
"world",
)
fmt.Println(s)
// Output:
//
// {
// "hello": "world"
// }
}