Files
undent/undent_example_test.go
Jim Myhrberg b2057429a1 fix(whitespace): remove leading line-break from input
This effectively cleans up what I consider syntactical sugar required
due to Go's syntax. For example:

    str := undent.String(`
        hello
        world`,
    )

In the above example I would consider the initial line-break after the
opening back-tick (`) character syntactical sugar, and hence should be
discarded from the final undented string.

However if the literal string contains more than one initial line-break,
only the first one should be removed, as the rest would intentionally be
part of the input.
2020-12-07 10:43:26 +00:00

49 lines
527 B
Go

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"
// }
}