Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions protectedby/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,15 @@ func getLock(pass *analysis.Pass, spec *ast.TypeSpec, c *ast.Comment) (*ast.Fiel
}

func getStructFieldByName(name string, st *ast.StructType) *ast.Field {
var lockField *ast.Field

for _, field := range st.Fields.List {
for _, n := range field.Names {
if name == n.Name {
lockField = field
break
return field
}
}
}

return lockField
return nil
}

// getLockName returns the first word in the comment after "protected by" statement or error if the statement is not
Expand Down
2 changes: 1 addition & 1 deletion protectedby/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func Test_getLockName(t *testing.T) {
}

if name != tc.expectedLockName {
t.Fatalf("expected lock name %q, got %q", tc.expectedError, err)
t.Fatalf("expected lock name %q, got %q", tc.expectedLockName, name)
}
})
}
Expand Down
Loading