Skip to content

Commit ac3e5e2

Browse files
committed
add nil check
Signed-off-by: sivchari <shibuuuu5@gmail.com>
1 parent 6384e29 commit ac3e5e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/analysis/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func LookupTypeSpec(pass *analysis.Pass, ident *ast.Ident) (*ast.TypeSpec, bool)
8080
// FieldName returns the name of the field. If the field has a name, it returns that name.
8181
// If the field is embedded and it can be converted to an identifier, it returns the name of the identifier.
8282
func FieldName(field *ast.Field) string {
83-
if len(field.Names) > 0 {
83+
if len(field.Names) > 0 && field.Names[0] != nil {
8484
return field.Names[0].Name
8585
}
8686

0 commit comments

Comments
 (0)