blob: 943e18aed525e3a9fc318a924caa0a75aab374db [file] [log] [blame]
<!--
Copyright 2021 The Go Authors. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
-->
{{define "title"}}
<title>{{.Query}} - Search Results · pkg.go.dev</title>
{{end}}
{{define "pre-content"}}
<link href="/static/frontend/search/search.css?version={{.AppVersionLabel}}" rel="stylesheet">
{{end}}
{{define "main"}}
<main class="go-Container">
<div class="go-Content SearchResults">
{{if eq .SearchMode "identifiers"}}
{{template "search_identifier" .}}
{{else}}
{{template "search_package" .}}
{{end}}
{{if gt (len .Results) 0}}
{{template "search_pagination" .}}
{{end}}
</div>
</main>
{{end}}
{{define "search_identifier"}}
<h1>Identifiers matching “{{.Query}}”</h1>
<a href="{{.Pagination.URL .Pagination.Limit "packages"}}">Search instead for “package: {{.Query}}”</a>
{{if gt (len .Results) 0}}
<div class="SearchResults-summary">
<div>
Found {{len $.Results}} matching identifiers (names of constants, variables, types,
functions, methods, and fields). <a href="/search-help">Search help.</a>
</div>
{{template "search_pagination" .}}
</div>
{{end}}
{{if eq (len .Results) 0}}
{{template "gopher-airplane" "No results found."}}
<p class="SearchResults-emptyContentMessage">
Try searching for a package by visiting <a href="https://pkg.go.dev/search?q={{.Query}}">pkg.go.dev/search?q={{.Query}}</a>.
</p>
{{else}}
{{template "search_identifier_results" .}}
{{end}}
{{end}}
{{define "search_identifier_results"}}
<div>
{{$query := .Query}}
{{range $i, $r := .Results}}
<div class="SearchSnippet">
<div class="SearchSnippet-headerContainer">
<h2>
<a href="{{.SymbolLink}}" data-gtmc="search result" data-gtmv="{{$i}}"
data-test-id="snippet-title">
<span class="SearchSnippet-symbolKind">{{.SymbolKind}}</span>
{{.SymbolName}}
</a>
<span class="SearchSnippet-header-dash">in</span>
<a href="/{{$r.PackagePath}}"
class="">{{$r.PackagePath}}</a>
</h2>
</div>
<div class="SearchSnippet-infoLabel go-textSubtle" data-test-id="snippet-synopsis">{{$r.Synopsis}}</div>
<pre class="SearchSnippet-symbolCode">{{.SymbolSynopsis}}</pre>
{{template "search_metadata" $r}}
</div> <!-- SearchSnippet -->
{{end}}
</div>
{{end}}
{{define "search_package"}}
<h1>Search results for “{{.Query}}”</h1>
<a href="{{.Pagination.URL .Pagination.Limit "identifiers"}}">Search instead for “identifier: {{.Query}}”</a>
{{if gt (len .Results) 0}}
<div class="SearchResults-summary">
<div>
Found {{len .Results}} modules with matching packages. <a href="/search-help">Search help.</a>
</div>
{{template "search_pagination" .}}
</div>
{{end}}
{{if eq (len .Results) 0}}
{{template "gopher-airplane" "No results found."}}
<p class="SearchResults-emptyContentMessage">
If you think “{{.Query}}” is a valid package or module, you could try downloading
it by visiting <a href="https://pkg.go.dev/{{.Query}}">pkg.go.dev/{{.Query}}</a>.
</p>
{{else}}
{{template "search_package_results" .}}
{{end}}
{{end}}
{{define "search_package_results"}}
<div>
{{$query := .Query}}
{{range $i, $v := .Results}}
<div class="SearchSnippet">
<div class="SearchSnippet-headerContainer">
<h2>
<a href="/{{$v.PackagePath}}" data-gtmc="search result" data-gtmv="{{$i}}"
data-test-id="snippet-title">
<span class="SearchSnippet-header-name">{{$v.Name}}</span>
<span class="SearchSnippet-header-dash"></span>
{{$v.PackagePath}}
</a>
</h2>
{{with $v.ChipText}}<span class="go-Chip go-Chip--inverted">{{.}}</span>{{end}}
</div>
<p class="SearchSnippet-synopsis" data-test-id="snippet-synopsis">
{{$v.Synopsis}}
</p>
{{template "search_metadata" $v}}
{{with .SameModule}}
{{$m := .}}
<div class="SearchSnippet-sub go-textSubtle">
<a href="{{$v.ModulePath}}#section-directories">{{.Heading}}</a>
{{range $i, $v := .Links}}
{{if lt $i 5}}
<a class="go-Chip go-Chip--subtle"
href="/{{$v.Href}}"
{{if gt $i 4 }}data-hidden="true"{{end}}
data-gtmc="search result same module"
data-gtmv="{{$i}}">
{{$v.Body}}
</a>
{{end}}
{{end}}
{{$more := subtract (len .Links) 5}}
{{if gt (len .Links) 5}}
<a href="{{$v.ModulePath}}#section-directories" class="go-Chip go-Chip--subtle"
data-gtmc="search result same module link">
+{{$more}} more
</a>
{{end}}
</div>
{{end}}
{{with .OtherMajor}}
<div class="SearchSnippet-sub go-textSubtle">
<span>{{.Heading}}</span>
{{range $i, $v := .Links}}
<a class="go-Chip go-Chip--subtle" href="/{{$v.Href}}"
data-gtmc="search result lower major" data-gtmv="{{$i}}">{{$v.Body}}</a>
{{end}}
</div>
{{end}}
</div> <!-- SearchSnippet -->
{{end}}
</div>
{{end}}
{{define "search_metadata"}}
<div class="SearchSnippet-infoLabel">
<a href="/{{$.PackagePath}}?tab=importedby" aria-label="Go to Imported By">
<span class="go-textSubtle">Imported by </span>{{.NumImportedBy}}
</a>
<span class="go-textSubtle">|</span>
<span class="go-textSubtle">
{{.DisplayVersion}} published on <span data-test-id="snippet-published">{{.CommitTime}}</span>
</span>
<span class="go-textSubtle">|</span>
<span data-test-id="snippet-license">
{{if .Licenses}}
<a href="/{{$.PackagePath}}?tab=licenses" aria-label="Go to Licenses">
{{commaseparate .Licenses}}
</a>
{{else}}
<span class="go-textSubtle">No license</span>
{{end}}
</span>
</div>
{{end}}
{{define "search_pagination"}}
{{ $p := .Pagination }}
<label class="go-Label go-Label--inline" data-test-id="pagination">
Show
<select name="limit" class="go-Select js-selectNav">
{{range $p.Limits}}
<option value="{{$p.URL . $.SearchMode}}"{{if eq . $p.Limit}} selected{{end}}>{{.}}</option>
{{end}}
</select>
results
</label>
{{end}}