mirror of
https://github.com/jimeh/undent.git
synced 2026-02-19 11:56:39 +00:00
fix(bytes): change Bytes function to accept string input but return a byte slice
The old method signature was just nonsensical, as you would always be providing indented values via a string literal. So it makes much more sense to have all methods accept a string argument, and then return different types. This also allows use of a `Bytesf` method. This is technically a breaking change, but I'm classifying it as a bugfix cause the old method signature was basically useless.
This commit is contained in:
@@ -7,11 +7,11 @@ import (
|
||||
)
|
||||
|
||||
func ExampleBytes() {
|
||||
b := undent.Bytes([]byte(`
|
||||
b := undent.Bytes(`
|
||||
{
|
||||
"hello": "world"
|
||||
}`,
|
||||
))
|
||||
)
|
||||
|
||||
fmt.Println(string(b))
|
||||
// Output:
|
||||
@@ -20,6 +20,20 @@ func ExampleBytes() {
|
||||
// }
|
||||
}
|
||||
|
||||
func ExampleBytesf() {
|
||||
s := undent.Bytesf(`
|
||||
{
|
||||
"hello": "%s"
|
||||
}`,
|
||||
"world",
|
||||
)
|
||||
fmt.Println(string(s))
|
||||
// Output:
|
||||
// {
|
||||
// "hello": "world"
|
||||
// }
|
||||
}
|
||||
|
||||
func ExampleString() {
|
||||
s := undent.String(`
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user