Skip to content

Commit

Permalink
refactor: refactor getBasicLitValue func
Browse files Browse the repository at this point in the history
  • Loading branch information
sashamelentyev committed Aug 26, 2022
1 parent 41ad014 commit 3a159e9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/analyzer/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,14 @@ func getBasicLitFromElts(elts []ast.Expr, key string) *ast.BasicLit {

// getBasicLitValue returns BasicLit value as string without quotes
func getBasicLitValue(basicLit *ast.BasicLit) string {
if basicLit == nil || len(basicLit.Value) == 0 || basicLit.Value == `""` {
return ""
}
var val strings.Builder
for i := range basicLit.Value {
switch basicLit.Value[i] {
case '\\', '"':
if basicLit.Value[i] == '"' {
continue
default:
} else {
val.WriteByte(basicLit.Value[i])
}
}
Expand Down

0 comments on commit 3a159e9

Please sign in to comment.