Skip to content

Commit

Permalink
Update http_const.go
Browse files Browse the repository at this point in the history
  • Loading branch information
mmorel-35 authored Jun 27, 2024
1 parent ea55091 commit 820e49e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/checkers/http_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ func newHTTPMethodReplacement(e ast.Expr) *analysis.SuggestedFix {
if !ok {
return nil
}
currentVal := unquoteBasicLitValue(bt)
currentVal, ok := unquoteBasicLitValue(bt)
if !ok {
return nil
}
key := strings.ToUpper(currentVal)
newVal, ok := httpMethod[key]
if !ok {
Expand Down Expand Up @@ -123,7 +126,10 @@ func newAnalysisDiagnostic(
}
}

func unquoteBasicLitValue(basicLit *ast.BasicLit) string {
s, _ := strconv.Unquote(basicLit.Value)
return s
func unquoteBasicLitValue(basicLit *ast.BasicLit) (string, bool) {
value, err := strconv.Unquote(basicLit.Value)
if err != nil {
return "", false
}
return value, true
}

0 comments on commit 820e49e

Please sign in to comment.