Skip to content

Commit

Permalink
Merge pull request #56 from sashamelentyev/feat/basiclitval
Browse files Browse the repository at this point in the history
feat: use strings.Builder instead of strings.Trim
  • Loading branch information
sashamelentyev committed Aug 26, 2022
2 parents c56afba + cef0d6f commit 0803ef3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/analyzer/analyzer.go
Expand Up @@ -416,7 +416,16 @@ func getBasicLitFromElts(elts []ast.Expr, key string) *ast.BasicLit {

// getBasicLitValue returns BasicLit value as string without quotes
func getBasicLitValue(basicLit *ast.BasicLit) string {
return strings.Trim(basicLit.Value, "\"")
var val strings.Builder
for i := range basicLit.Value {
switch basicLit.Value[i] {
case '\\', '"':
continue
default:
val.WriteByte(basicLit.Value[i])
}
}
return val.String()
}

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

0 comments on commit 0803ef3

Please sign in to comment.