Debian Codegraph @

go/analysis/passes/modernize/testdata/src/stringscutprefix/stringscutprefix_dot.go

raw
1 package stringscutprefix
2
3 import (
4 . "strings"
5 )
6
7 // test supported cases of pattern 1 - CutPrefix
8 func _() {
9 if HasPrefix(s, pre) { // want "HasPrefix \\+ TrimPrefix can be simplified to CutPrefix"
10 a := TrimPrefix(s, pre)
11 _ = a
12 }
13 }
14
15 // test supported cases of pattern 1 - CutSuffix
16 func _() {
17 if HasSuffix(s, suf) { // want "HasSuffix \\+ TrimSuffix can be simplified to CutSuffix"
18 a := TrimSuffix(s, suf)
19 _ = a
20 }
21 }
22
23 // test supported cases of pattern2 - CutPrefix
24 func _() {
25 if after := TrimPrefix(s, pre); after != s { // want "TrimPrefix can be simplified to CutPrefix"
26 println(after)
27 }
28 if after := TrimPrefix(s, pre); s != after { // want "TrimPrefix can be simplified to CutPrefix"
29 println(after)
30 }
31 }
32
33 // test supported cases of pattern2 - CutSuffix
34 func _() {
35 if before := TrimSuffix(s, suf); before != s { // want "TrimSuffix can be simplified to CutSuffix"
36 println(before)
37 }
38 if before := TrimSuffix(s, suf); s != before { // want "TrimSuffix can be simplified to CutSuffix"
39 println(before)
40 }
41 }