Help us shape the future of Go! Take the 2026 Go Developer Survey

github

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package github provides a client for the GitHub REST API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the GitHub API client backed by go-gh.

func NewClient

func NewClient(creds Credentials) (*Client, error)

NewClient creates a new GitHub API client using go-gh.

func NewClientWithTransport

func NewClientWithTransport(creds Credentials, transport http.RoundTripper) (*Client, error)

NewClientWithTransport creates a GitHub API client with a custom HTTP transport. Intended for use in tests (e.g. pointing the client at an httptest.Server).

func (*Client) ListTeamRepos

func (c *Client) ListTeamRepos(ctx context.Context, org, teamSlug string) ([]Repository, error)

ListTeamRepos lists repositories for a team, handling Link-header pagination.

func (*Client) ListUserTeams

func (c *Client) ListUserTeams(ctx context.Context, org string) ([]Team, error)

ListUserTeams lists teams for the authenticated user, filtered to a specific org.

func (*Client) ListWorkflowRuns

func (c *Client) ListWorkflowRuns(ctx context.Context, owner, repo string, workflowID int64, branch string, from, to time.Time) ([]WorkflowRun, error)

ListWorkflowRuns lists runs for a specific workflow, filtered by date range.

func (*Client) ListWorkflows

func (c *Client) ListWorkflows(ctx context.Context, owner, repo string) ([]Workflow, error)

ListWorkflows lists GitHub Actions workflows for a repository.

func (*Client) TestConnection

func (c *Client) TestConnection(ctx context.Context) error

TestConnection verifies the GitHub credentials work.

func (*Client) WhoAmI

func (c *Client) WhoAmI(ctx context.Context) (*User, error)

WhoAmI returns the authenticated GitHub user. Useful for printing a "Connected as ..." line after credentials are saved.

func (*Client) WithDebug

func (c *Client) WithDebug(v bool) *Client

WithDebug toggles per-request debug logging.

func (*Client) WithDumpResponses

func (c *Client) WithDumpResponses(v bool) *Client

WithDumpResponses toggles full response-body dumping. Off by default.

type Credentials

type Credentials struct {
	Token string // Personal access token or GitHub App token
	Org   string // GitHub organization name
}

Credentials holds GitHub authentication details.

type Repository

type Repository struct {
	ID       int64           `json:"id"`
	Name     string          `json:"name"`
	FullName string          `json:"full_name"`
	Owner    RepositoryOwner `json:"owner"`
	Private  bool            `json:"private"`
	Archived bool            `json:"archived"`
	HTMLURL  string          `json:"html_url"`
}

Repository represents a GitHub repository.

type RepositoryOwner

type RepositoryOwner struct {
	Login string `json:"login"`
}

RepositoryOwner represents the owner of a GitHub repository.

type Team

type Team struct {
	ID           int64   `json:"id"`
	Slug         string  `json:"slug"`
	Name         string  `json:"name"`
	Organization TeamOrg `json:"organization"`
}

Team represents a GitHub team.

type TeamOrg

type TeamOrg struct {
	Login string `json:"login"`
}

TeamOrg represents the organization a team belongs to.

type User

type User struct {
	Login string `json:"login"`
	Name  string `json:"name,omitempty"`
}

User is the subset of GitHub's /user response we care about. Populated by WhoAmI for the "Connected as ..." setup-confirmation line.

type Workflow

type Workflow struct {
	ID    int64  `json:"id"`
	Name  string `json:"name"`
	Path  string `json:"path"`
	State string `json:"state"`
}

Workflow represents a GitHub Actions workflow.

type WorkflowListResponse

type WorkflowListResponse struct {
	TotalCount int        `json:"total_count"`
	Workflows  []Workflow `json:"workflows"`
}

WorkflowListResponse represents the response from listing workflows.

type WorkflowRun

type WorkflowRun struct {
	ID         int64     `json:"id"`
	Name       string    `json:"name"`
	Status     string    `json:"status"`
	Conclusion string    `json:"conclusion"`
	HeadBranch string    `json:"head_branch"`
	CreatedAt  time.Time `json:"created_at"`
	UpdatedAt  time.Time `json:"updated_at"`
	RunNumber  int       `json:"run_number"`
	HTMLURL    string    `json:"html_url"`
}

WorkflowRun represents a single GitHub Actions workflow run.

type WorkflowRunsResponse

type WorkflowRunsResponse struct {
	TotalCount   int           `json:"total_count"`
	WorkflowRuns []WorkflowRun `json:"workflow_runs"`
}

WorkflowRunsResponse represents the response from listing workflow runs.

Jump to

Keyboard shortcuts

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