Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.0.0-20201028153306-37f0764111ff / refactor / eg / testdata / C1.go
1 // +build ignore
2
3 package C1
4
5 import "strings"
6
7 func example() {
8         x := "foo"
9         println(x[:len(x)])
10
11         // Match, but the transformation is not sound w.r.t. possible side effects.
12         println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 3))])
13
14         // No match, since second use of wildcard doesn't match first.
15         println(strings.Repeat("*", 3)[:len(strings.Repeat("*", 2))])
16
17         // Recursive match demonstrating bottom-up rewrite:
18         // only after the inner replacement occurs does the outer syntax match.
19         println((x[:len(x)])[:len(x[:len(x)])])
20         // -> (x[:len(x)])
21         // -> x
22 }