1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:24:54 -07:00
go/refactor/eg/testdata/C1.golden
Alan Donovan bfcffc697d go.tools/refactor/eg: an example-based refactoring tool.
See refactor/eg/eg.go for details.

LGTM=crawshaw
R=crawshaw, gri, kamil.kisiel, josharian
CC=golang-codereviews
https://golang.org/cl/81010043
2014-04-02 12:24:55 -04:00

23 lines
498 B
Plaintext

// +build ignore
package C1
import "strings"
func example() {
x := "foo"
println(x)
// Match, but the transformation is not sound w.r.t. possible side effects.
println(strings.Repeat("*", 3))
// No match, since second use of wildcard doesn't match first.
println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 2))])
// Recursive match demonstrating bottom-up rewrite:
// only after the inner replacement occurs does the outer syntax match.
println(x)
// -> (x[:len(x)])
// -> x
}