refactor: clean up verbose and redundant comments
Trim or remove comments that: - State the obvious (function names already convey purpose) - Repeat what the code clearly shows - Are excessively long without adding value Keep comments that explain *why*, not *what*.
This commit is contained in:
parent
805e7ffdc2
commit
5b942a5fd6
11 changed files with 16 additions and 102 deletions
|
|
@ -27,8 +27,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// Service fetches search suggestions from an upstream metasearch instance
|
||||
// or falls back to Wikipedia's OpenSearch API.
|
||||
// Service fetches search suggestions from upstream or Wikipedia OpenSearch.
|
||||
type Service struct {
|
||||
upstreamURL string
|
||||
http *http.Client
|
||||
|
|
@ -44,7 +43,6 @@ func NewService(upstreamURL string, timeout time.Duration) *Service {
|
|||
}
|
||||
}
|
||||
|
||||
// Suggestions returns search suggestions for the given query.
|
||||
func (s *Service) Suggestions(ctx context.Context, query string) ([]string, error) {
|
||||
if strings.TrimSpace(query) == "" {
|
||||
return nil, nil
|
||||
|
|
@ -56,7 +54,6 @@ func (s *Service) Suggestions(ctx context.Context, query string) ([]string, erro
|
|||
return s.wikipediaSuggestions(ctx, query)
|
||||
}
|
||||
|
||||
// upstreamSuggestions proxies to an upstream /autocompleter endpoint.
|
||||
func (s *Service) upstreamSuggestions(ctx context.Context, query string) ([]string, error) {
|
||||
u := s.upstreamURL + "/autocompleter?" + url.Values{"q": {query}}.Encode()
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue