mirror of
https://github.com/jimeh/undent.git
synced 2026-02-19 11:56:39 +00:00
feat(undent): add initial implementation of String, Stringf, and Bytes
This commit is contained in:
51
undent_example_test.go
Normal file
51
undent_example_test.go
Normal 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"
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user