-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Search: solidify conversion to Zoekt queries #60349
Conversation
internal/search/zoekt/query.go
Outdated
func toLangFilters(langs []string) []zoekt.Q { | ||
var filters []zoekt.Q | ||
for _, lang := range langs { | ||
lang, _ = enry.GetLanguageByAlias(lang) // Invariant: lang is valid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know Go doesn't have built-in assertions and it's documented why, but I think it would be helpful to assert that the second return value is true to catch potential bugs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By "assert" do you mean check the value and return an error? Unfortunately that makes this quite verbose and less readable. For "runtime assertions", do we ever use panic? I haven't seen this used in our Go code, maybe it goes against the spirit of Go's design.
For now I didn't touch this (as it's a pre-existing issue) but would be interested in your thoughts!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left some minor suggestions and questions. 👍🏽
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
For the 'search-content-based-lang-detection' feature, this PR improves how filters are converted to Zoekt queries:
-lang:go
Relates to https://github.com/sourcegraph/sourcegraph/issues/60341
Test plan
Added new unit tests, manual testing