Fix quote function in template to render pointers properly
This commit is contained in:
parent
99419c75bc
commit
ed30be05bc
2 changed files with 4 additions and 0 deletions
|
@ -219,6 +219,8 @@ func quote(input interface{}) string {
|
||||||
inputStr = input
|
inputStr = input
|
||||||
case fmt.Stringer:
|
case fmt.Stringer:
|
||||||
inputStr = input.String()
|
inputStr = input.String()
|
||||||
|
case *string:
|
||||||
|
inputStr = *input
|
||||||
default:
|
default:
|
||||||
inputStr = fmt.Sprintf("%v", input)
|
inputStr = fmt.Sprintf("%v", input)
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,10 +256,12 @@ func TestFormatIP(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestQuote(t *testing.T) {
|
func TestQuote(t *testing.T) {
|
||||||
|
foo := "foo"
|
||||||
cases := map[interface{}]string{
|
cases := map[interface{}]string{
|
||||||
"foo": `"foo"`,
|
"foo": `"foo"`,
|
||||||
"\"foo\"": `"\"foo\""`,
|
"\"foo\"": `"\"foo\""`,
|
||||||
"foo\nbar": `"foo\nbar"`,
|
"foo\nbar": `"foo\nbar"`,
|
||||||
|
&foo: `"foo"`,
|
||||||
10: `"10"`,
|
10: `"10"`,
|
||||||
}
|
}
|
||||||
for input, output := range cases {
|
for input, output := range cases {
|
||||||
|
|
Loading…
Reference in a new issue