Source File
index.go
Belonging Package
golang.org/x/pkgsite/internal/index
package index
import (
)
httpClient *http.Client
}
func ( string) ( *Client, error) {
defer derrors.Add(&, "index.New(%q)", )
, := url.Parse()
if != nil {
return nil, fmt.Errorf("url.Parse(%q): %v", , )
}
if .Scheme != "https" {
return nil, fmt.Errorf("scheme must be https (got %s)", .Scheme)
}
return &Client{url: strings.TrimRight(, "/"), httpClient: &http.Client{Transport: &ochttp.Transport{}}}, nil
}
func ( *Client) ( time.Time, int) string {
:= url.Values{}
.Set("since", .Format(time.RFC3339))
if > 0 {
.Set("limit", strconv.Itoa())
}
return fmt.Sprintf("%s?%s", .url, .Encode())
}
func ( *Client) ( context.Context, time.Time, int) ( []*internal.IndexVersion, error) {
defer derrors.Wrap(&, "index.Client.GetVersions(ctx, %s, %d)", , )
:= .pollURL(, )
, := ctxhttp.Get(, .httpClient, )
if != nil {
return nil, fmt.Errorf("ctxhttp.Get(ctx, nil, %q): %v", , )
}
defer .Body.Close()
var []*internal.IndexVersion
:= json.NewDecoder(.Body)
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |