strings.Diff
语法
strings.Diff OLDNAME OLD NEWNAME NEW
返回
string
使用 strings.Diff
比较两个字符串并渲染高亮差异
{{ $want := `
<p>The product of 6 and 7 is 42.</p>
<p>The product of 7 and 6 is 42.</p>
`}}
{{ $got := `
<p>The product of 6 and 7 is 42.</p>
<p>The product of 7 and 6 is 13.</p>
`}}
{{ $diff := strings.Diff "want" $want "got" $got }}
{{ transform.Highlight $diff "diff" }}
已渲染