Skip to content

Commit 56978f7

Browse files
committed
review: Use strings.CutPrefix
Signed-off-by: Kemal Akkoyun <[email protected]>
1 parent df889d9 commit 56978f7

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

errorlint/lint.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,8 @@ func LintErrorTypeAssertions(fset *token.FileSet, info *TypesInfoExt) []analysis
475475
targetType := exprToString(typeAssert.Type)
476476
errExpr := exprToString(typeAssert.X)
477477

478-
// Check if the type is a pointer type,
479-
isPointerType := strings.HasPrefix(targetType, "*")
480-
// If it's not a pointer type, we'll need to create a variable of the same type
481-
// but still need to pass its address to errors.As.
482-
baseType := targetType
483-
if isPointerType {
484-
baseType = strings.TrimPrefix(targetType, "*")
485-
}
478+
// Check if the type is a pointer type
479+
baseType, isPointerType := strings.CutPrefix(targetType, "*")
486480

487481
parent := info.NodeParent[typeAssert]
488482

0 commit comments

Comments
 (0)