Skip to content

Commit c02a771

Browse files
authored
chore: align golang/x/tools (#95)
Align with upstream: golang/tools#395 Signed-off-by: Timon Wong <[email protected]>
1 parent 07f29af commit c02a771

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

.golangci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ issues:
8686
- path: _test\.go
8787
linters:
8888
- mnd
89+
- path: internal/checkers/printf/printf.go
90+
linters:
91+
- gocritic
8992
exclude-dirs:
9093
- testdata
9194

internal/checkers/printf/printf.go

+3-10
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,6 @@ func (s *formatState) scanNum() {
9090
}
9191
}
9292

93-
func stringIndexAt(s, substr string, start int) int {
94-
idx := strings.Index(s[start:], substr)
95-
if idx < 0 {
96-
return idx
97-
}
98-
return idx + start
99-
}
100-
10193
// parseIndex scans an index expression. It returns false if there is a syntax error.
10294
func (s *formatState) parseIndex() bool {
10395
if s.nbytes == len(s.format) || s.format[s.nbytes] != '[' {
@@ -109,11 +101,12 @@ func (s *formatState) parseIndex() bool {
109101
s.scanNum()
110102
ok := true
111103
if s.nbytes == len(s.format) || s.nbytes == start || s.format[s.nbytes] != ']' {
112-
ok = false
113-
s.nbytes = stringIndexAt(s.format, "]", start)
104+
ok = false // syntax error is either missing "]" or invalid index.
105+
s.nbytes = strings.Index(s.format[start:], "]")
114106
if s.nbytes < 0 {
115107
return false
116108
}
109+
s.nbytes = s.nbytes + start
117110
}
118111
arg32, err := strconv.ParseInt(s.format[start:s.nbytes], 10, 32)
119112
if err != nil || !ok || arg32 <= 0 {

0 commit comments

Comments
 (0)