Documentation ¶
Overview ¶
Package codesearch wraps up the codesearch JSON API.
Notes about the codesearch REST API:
The query needs to be bracketed by search_request=[b|e] query parameters.
For example:
https://cs.chromium.org/codesearch/json/search_request:1 ?search_request=b &query=file%3A.md+file%3A%5Esrc%2Fthird_party%2Fskia%2F+package%3A%5Echromium%24 &max_num_results=20 &results_offset=0 &search_request=e
The URL for a file.name of "src/third_party/skia/site/roles.md" is
https://cs.chromium.org/chromium/src/third_party/skia/site/roles.md
To jump to a specific line:
https://cs.chromium.org/chromium/src/third_party/skia/site/roles.md?l=2
Index ¶
Constants ¶
const ( // SkiaAllCode is the text to add to a search to restrict it to the Skia // codebase. SkiaAllCode = "file:^src/third_party/skia/ package:^chromium$" // SkiaInfraBaseQuery is the text to add to a search to restrict it to the // Skia Infra codebase. SkiaInfraBaseQuery = "file:^skia/buildbot/ package:^chromium$" // SkiaAllMarkdown is the text to add to a search to restrict it to Markdown // files in either the buildbot or skia proper repo. SkiaAllMarkdown = "lang:^markdown$ AND (file:^skia/buildbot/ OR file:^src/third_party/skia/) AND package:^chromium$ " )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CodeSearch ¶
type CodeSearch struct {
// contains filtered or unexported fields
}
CodeSearch searches code.
func (*CodeSearch) Origin ¶
func (cs *CodeSearch) Origin(origin string)
Origin allows over-riding the default origin.
func (CodeSearch) Query ¶
func (cs CodeSearch) Query(ctx context.Context, q string, params url.Values) (SearchResponse, error)
Query runs a search against the given search service.
The query string should conform to any query you would use on https://cs.chromium.org/.
func (CodeSearch) URL ¶
func (cs CodeSearch) URL(r SearchResult) string
URL returns the link to display the TopFile in the SearchResult.
type CompoundSearchResponse ¶
type CompoundSearchResponse struct {
Response []SearchResponse `json:"search_response"`
}
CompoundSearchResponse represents multiple search responses.
type SearchResponse ¶
type SearchResponse struct { Status int `json:"status"` StatusMessage string `json:"status_message"` EstimatedTotalNumberOfResults int `json:"estimated_total_number_of_results"` ResultsOffset int `json:"results_offset"` NextPageToken string `json:"next_page_token"` SearchResult []SearchResult `json:"search_result"` }
SearchResponse is the response from CodeSearch.Query.
type SearchResult ¶
type SearchResult struct { TopFile TopFile `json:"top_file"` NumDuplicates int `json:"num_duplicates"` NumMatches int `json:"num_matches"` Language string `json:"language"` BestMatchingLineNumber int `json:"best_matching_line_number"` Snippet []Snippet `json:"snippet"` }
SearchResult is a single result from a search.