Skip to content

Commit 3a159e9

Browse files
refactor: refactor getBasicLitValue func
1 parent 41ad014 commit 3a159e9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

pkg/analyzer/analyzer.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,12 +420,14 @@ func getBasicLitFromElts(elts []ast.Expr, key string) *ast.BasicLit {
420420

421421
// getBasicLitValue returns BasicLit value as string without quotes
422422
func getBasicLitValue(basicLit *ast.BasicLit) string {
423+
if basicLit == nil || len(basicLit.Value) == 0 || basicLit.Value == `""` {
424+
return ""
425+
}
423426
var val strings.Builder
424427
for i := range basicLit.Value {
425-
switch basicLit.Value[i] {
426-
case '\\', '"':
428+
if basicLit.Value[i] == '"' {
427429
continue
428-
default:
430+
} else {
429431
val.WriteByte(basicLit.Value[i])
430432
}
431433
}

0 commit comments

Comments
 (0)