Skip to content

Commit abc5de8

Browse files
authored
[searcher] Add SearchOption and handle host error (#1173)
## Summary 1. Add `SearchOption` for better declaration 2. Handle the error from parsing hosts ## How was it tested? DEVBOX_SEARCH_HOST=foo devbox search hello
1 parent 8d000ba commit abc5de8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

internal/searcher/client.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func Client() *client {
3232
}
3333
}
3434

35-
func (c *client) Search(query string, options ...func() string) (*SearchResult, error) {
35+
func (c *client) Search(query string, options ...SearchOption) (*SearchResult, error) {
3636
if query == "" {
3737
return nil, fmt.Errorf("query should not be empty")
3838
}
@@ -50,7 +50,10 @@ func (c *client) Search(query string, options ...func() string) (*SearchResult,
5050
return execSearch(searchURL)
5151
}
5252

53-
func WithVersion(version string) func() string {
53+
// SearchOption returns a string for query to be appended to the endpoint
54+
type SearchOption func() string
55+
56+
func WithVersion(version string) SearchOption {
5457
return func() string {
5558
return "&v=" + url.QueryEscape(version)
5659
}

0 commit comments

Comments
 (0)