Skip to content

Commit cef0d6f

Browse files
feat: use strings.Builder instead of strings.Trim
1 parent c56afba commit cef0d6f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pkg/analyzer/analyzer.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,16 @@ func getBasicLitFromElts(elts []ast.Expr, key string) *ast.BasicLit {
416416

417417
// getBasicLitValue returns BasicLit value as string without quotes
418418
func getBasicLitValue(basicLit *ast.BasicLit) string {
419-
return strings.Trim(basicLit.Value, "\"")
419+
var val strings.Builder
420+
for i := range basicLit.Value {
421+
switch basicLit.Value[i] {
422+
case '\\', '"':
423+
continue
424+
default:
425+
val.WriteByte(basicLit.Value[i])
426+
}
427+
}
428+
return val.String()
420429
}
421430

422431
func report(pass *analysis.Pass, pos token.Pos, currentVal, newVal string) {

0 commit comments

Comments
 (0)