search

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package search provides GitHub search API functionality.

Index

Constants

View Source
const (
	ParamUser  = "user"
	ParamState = "state"
	ParamIs    = "is"
	ParamOrg   = "org"
	ParamRepo  = "repo"
	ParamType  = "type"
)

Query parameter names.

View Source
const (
	ParamStateValueOpen   = "open"
	ParamStateValueClosed = "closed"
	ParamIsValuePR        = "pr"
	ParamIsValueIssue     = "issue"
)

Query parameter values.

View Source
const (
	ParamPerPageValueMax     = 100
	ParamPerPageValueDefault = 30
)

Pagination constants.

Variables

View Source
var (
	ErrIssueIsNotSet                 = errors.New("issue is not set")
	ErrUserIsNotSet                  = errors.New("user is not set")
	ErrUserLoginIsNotSet             = errors.New("user login is not set")
	ErrIssueCreatedAtIsNotSet        = errors.New("issue created at is not set")
	ErrIssueCreatedAtGetTimeIsNotSet = errors.New("issue created at gettime is not set")
)

Issue-related errors.

Functions

This section is empty.

Types

type Client

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

Client wraps the GitHub client for search operations.

func NewClient

func NewClient(ghClient *github.Client) *Client

NewClient creates a new search client.

func (*Client) SearchIssues

func (c *Client) SearchIssues(ctx context.Context, qry Query, opts *github.SearchOptions) (*github.IssuesSearchResult, *github.Response, error)

SearchIssues is a wrapper for SearchService.Issues().

func (*Client) SearchIssuesAll

func (c *Client) SearchIssuesAll(ctx context.Context, qry Query, opts *github.SearchOptions) (Issues, error)

SearchIssuesAll retrieves all issues matching the query with pagination.

func (*Client) SearchOpenPullRequests

func (c *Client) SearchOpenPullRequests(ctx context.Context, username string, opts *github.SearchOptions) (*github.IssuesSearchResult, *github.Response, error)

SearchOpenPullRequests searches for open pull requests by username.

type Issue

type Issue struct {
	*github.Issue
}

Issue wraps a GitHub issue with helper methods.

func (*Issue) AuthorUserID

func (is *Issue) AuthorUserID() (int64, error)

AuthorUserID returns the author's user ID.

func (*Issue) AuthorUsername

func (is *Issue) AuthorUsername() (string, error)

AuthorUsername returns the author's username.

func (*Issue) CreatedAge

func (is *Issue) CreatedAge() (time.Duration, error)

CreatedAge returns the duration since the issue was created.

func (*Issue) CreatedTime

func (is *Issue) CreatedTime() (time.Time, error)

CreatedTime returns the issue creation time.

func (*Issue) MustAuthorUserID

func (is *Issue) MustAuthorUserID() int64

MustAuthorUserID returns the author user ID or -1 on error.

func (*Issue) MustAuthorUsername

func (is *Issue) MustAuthorUsername() string

MustAuthorUsername returns the author username or empty string on error.

type Issues

type Issues []*github.Issue

Issues is a slice of GitHub issues.

func (Issues) RepositoryIssueCounts

func (iss Issues) RepositoryIssueCounts(htmlURLs bool) map[string]int

RepositoryIssueCounts returns a map of repository URLs to issue counts.

func (Issues) Table

func (iss Issues) Table(name string) (*table.Table, error)

Table creates a table of issues.

func (Issues) TableRepos

func (iss Issues) TableRepos(name string, htmlURLs bool) *table.Table

TableRepos creates a table of repositories with issue counts.

func (Issues) TableSet

func (iss Issues) TableSet() (*table.TableSet, error)

TableSet returns a table set with issues and repositories.

type Query

type Query map[string]string

Query represents a GitHub search query.

func (Query) Encode

func (q Query) Encode() string

Encode implements GitHub API query encoding. Keys are sorted to ensure deterministic output.

type QueryBuilder

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

QueryBuilder provides a fluent interface for constructing search queries. It wraps the Query map type, providing type-safe methods for common qualifiers while preserving flexibility through the Set() method for any qualifier.

func NewQuery

func NewQuery() *QueryBuilder

NewQuery creates a new QueryBuilder for constructing search queries.

func (*QueryBuilder) Assignee

func (qb *QueryBuilder) Assignee(username string) *QueryBuilder

Assignee filters by assigned user.

func (*QueryBuilder) Author

func (qb *QueryBuilder) Author(username string) *QueryBuilder

Author filters by item creator.

func (*QueryBuilder) Build

func (qb *QueryBuilder) Build() Query

Build returns the constructed Query map.

func (*QueryBuilder) Involves

func (qb *QueryBuilder) Involves(username string) *QueryBuilder

Involves filters by user involvement (author, assignee, mentions, or commenter).

func (*QueryBuilder) Is

func (qb *QueryBuilder) Is(value string) *QueryBuilder

Is filters by type or state (pr, issue, open, closed, merged, etc.).

func (*QueryBuilder) IsIssue

func (qb *QueryBuilder) IsIssue() *QueryBuilder

IsIssue filters for issues only.

func (*QueryBuilder) IsPR

func (qb *QueryBuilder) IsPR() *QueryBuilder

IsPR filters for pull requests only.

func (*QueryBuilder) Label

func (qb *QueryBuilder) Label(label string) *QueryBuilder

Label filters by label.

func (*QueryBuilder) Mentions

func (qb *QueryBuilder) Mentions(username string) *QueryBuilder

Mentions filters by mentioned user.

func (*QueryBuilder) Org

func (qb *QueryBuilder) Org(org string) *QueryBuilder

Org filters by organization.

func (*QueryBuilder) Repo

func (qb *QueryBuilder) Repo(repo string) *QueryBuilder

Repo filters by specific repository (owner/repo format).

func (*QueryBuilder) Set

func (qb *QueryBuilder) Set(key, value string) *QueryBuilder

Set adds any key-value pair to the query. Use this for qualifiers not covered by the typed methods, or for new GitHub search qualifiers.

func (*QueryBuilder) State

func (qb *QueryBuilder) State(state string) *QueryBuilder

State filters by issue/PR state (open, closed).

func (*QueryBuilder) StateClosed

func (qb *QueryBuilder) StateClosed() *QueryBuilder

StateClosed filters for closed issues/PRs.

func (*QueryBuilder) StateOpen

func (qb *QueryBuilder) StateOpen() *QueryBuilder

StateOpen filters for open issues/PRs.

func (*QueryBuilder) Type

func (qb *QueryBuilder) Type(typ string) *QueryBuilder

Type filters by type (pr, issue).

func (*QueryBuilder) User

func (qb *QueryBuilder) User(username string) *QueryBuilder

User filters by repository owner username.

Jump to

Keyboard shortcuts

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