client

package
v1.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoToken = errors.New("no github token")

Functions

func APICacheFilePath

func APICacheFilePath(cacheDir, rawURL string) string

func CacheFilePath

func CacheFilePath(cacheDir, rawURL string) string

func Download

func Download(rawURL string, out io.Writer, getbar func(size int64) io.Writer, opts Options) error

func Get

func Get(rawURL string, disableSSL bool) (*http.Response, error)

func GetWithOptions

func GetWithOptions(rawURL string, opts Options) (*http.Response, error)

func ProxyFuncFor

func ProxyFuncFor(proxyURL string) (func(*http.Request) (*url.URL, error), error)

func SetAPICacheNoticeWriter

func SetAPICacheNoticeWriter(writer io.Writer) io.Writer

func SetDownloadGetWithOptionsForTest

func SetDownloadGetWithOptionsForTest(fn func(url string, opts Options) (*http.Response, error)) func()

func SetHTTPDoForTest

func SetHTTPDoForTest(fn func(client *http.Client, req *http.Request) (*http.Response, error)) func()

func SetProxyNoticeWriter

func SetProxyNoticeWriter(writer io.Writer) io.Writer

func SetVerbose

func SetVerbose(enabled bool, writer io.Writer)

func VerboseEnabledForTest

func VerboseEnabledForTest() bool

func Verbosef

func Verbosef(format string, args ...any)

Types

type Asset

type Asset struct {
	Name          string    `json:"name"`
	Size          int64     `json:"size,omitempty"`
	DownloadCount int       `json:"download_count,omitempty"`
	UpdatedAt     time.Time `json:"updated_at,omitempty"`
	URL           string    `json:"url,omitempty"`
}

type GitHubClient

type GitHubClient struct {
	// contains filtered or unexported fields
}

func NewGitHubClient

func NewGitHubClient(opts Options) *GitHubClient

func NewGitHubClientWithGetter

func NewGitHubClientWithGetter(opts Options, get HTTPGetFunc) *GitHubClient

func (*GitHubClient) Get

func (c *GitHubClient) Get(rawURL string) (*http.Response, error)

func (*GitHubClient) LatestRelease

func (c *GitHubClient) LatestRelease(repo string, includePrerelease bool) (Release, error)

func (*GitHubClient) LatestReleaseInfo

func (c *GitHubClient) LatestReleaseInfo(repo string) (string, time.Time, error)

func (*GitHubClient) ListReleases

func (c *GitHubClient) ListReleases(repo string, limit int, includePrerelease bool) ([]Release, error)

func (*GitHubClient) ReleaseAssets

func (c *GitHubClient) ReleaseAssets(repo, tag string) ([]Asset, error)

func (*GitHubClient) RepoInfo

func (c *GitHubClient) RepoInfo(repo string) (RepoInfo, error)

func (*GitHubClient) SearchRepositories

func (c *GitHubClient) SearchRepositories(query string, limit int, sort, order string) (SearchResult, error)

type HTTPGetFunc

type HTTPGetFunc func(url string, opts Options) (*http.Response, error)

type HTTPGetterFunc

type HTTPGetterFunc func(url string) (*http.Response, error)

func NewHTTPGetter

func NewHTTPGetter(opts Options) HTTPGetterFunc

func (HTTPGetterFunc) Get

func (f HTTPGetterFunc) Get(url string) (*http.Response, error)

type Options

type Options struct {
	ProxyURL          string
	APICacheEnabled   bool
	APICacheDir       string
	APICacheTime      int
	GhproxyEnabled    bool
	GhproxyHostURL    string
	GhproxySupportAPI bool
	GhproxyFallbacks  []string
	DisableSSL        bool
}

type RateLimit

type RateLimit struct {
	Limit     int   `json:"limit"`
	Remaining int   `json:"remaining"`
	Reset     int64 `json:"reset"`
}

func GetRateLimit

func GetRateLimit(opts Options) (RateLimit, error)

func (RateLimit) ResetTime

func (r RateLimit) ResetTime() time.Time

type RateLimitJSON

type RateLimitJSON struct {
	Resources map[string]RateLimit `json:"resources"`
}

type Release

type Release struct {
	Tag         string    `json:"tag"`
	Name        string    `json:"name,omitempty"`
	PublishedAt time.Time `json:"published_at,omitempty"`
	Prerelease  bool      `json:"prerelease,omitempty"`
	AssetsCount int       `json:"assets_count,omitempty"`
}

type RepoInfo

type RepoInfo struct {
	Repo          string    `json:"repo"`
	Description   string    `json:"description,omitempty"`
	Homepage      string    `json:"homepage,omitempty"`
	DefaultBranch string    `json:"default_branch,omitempty"`
	Stars         int       `json:"stars,omitempty"`
	Forks         int       `json:"forks,omitempty"`
	OpenIssues    int       `json:"open_issues,omitempty"`
	UpdatedAt     time.Time `json:"updated_at,omitempty"`
}

type SearchRepo

type SearchRepo struct {
	FullName        string    `json:"full_name,omitempty"`
	Description     string    `json:"description,omitempty"`
	HTMLURL         string    `json:"html_url,omitempty"`
	Homepage        string    `json:"homepage,omitempty"`
	Language        string    `json:"language,omitempty"`
	StargazersCount int       `json:"stargazers_count,omitempty"`
	ForksCount      int       `json:"forks_count,omitempty"`
	OpenIssuesCount int       `json:"open_issues_count,omitempty"`
	UpdatedAt       time.Time `json:"updated_at,omitempty"`
	Archived        bool      `json:"archived,omitempty"`
	Private         bool      `json:"private,omitempty"`
}

type SearchResult

type SearchResult struct {
	Query      string       `json:"query"`
	TotalCount int          `json:"total_count"`
	Items      []SearchRepo `json:"items,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL