or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

actions.mdadditional-services.mdapps.mdchecks.mdclient.mdenterprise.mdgit.mdindex.mdissues.mdorganizations.mdrepositories.mdteams.mdusers.md
tile.json

tessl/golang-github-com-google-go-github

Go client library for accessing the GitHub API v3

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
golangpkg:golang/github.com/google/go-github/v79@79.0.x

To install, run

npx @tessl/cli install tessl/golang-github-com-google-go-github@79.0.0

index.mddocs/

go-github

Go client library for accessing the GitHub API v3, providing comprehensive, strongly-typed access to all GitHub REST API endpoints with built-in support for authentication, rate limiting, and pagination.

Package Information

  • Package Name: github.com/google/go-github/v79/github
  • Package Type: golang
  • Language: Go
  • Version: v79.0.0
  • Installation: go get github.com/google/go-github/v79/github
  • Repository: https://github.com/google/go-github

Core Imports

import (
    "context"
    "github.com/google/go-github/v79/github"
)

For authentication with OAuth2:

import (
    "golang.org/x/oauth2"
    "github.com/google/go-github/v79/github"
)

Basic Usage

package main

import (
    "context"
    "fmt"
    "github.com/google/go-github/v79/github"
)

func main() {
    // Create an unauthenticated client
    client := github.NewClient(nil)

    // Or create an authenticated client with a token
    client = github.NewClient(nil).WithAuthToken("your-token")

    // Use context for all API calls
    ctx := context.Background()

    // List repositories for a user
    repos, resp, err := client.Repositories.List(ctx, "octocat", nil)
    if err != nil {
        panic(err)
    }

    // Check rate limit from response
    fmt.Printf("Rate limit: %d/%d\n", resp.Rate.Remaining, resp.Rate.Limit)

    // Access repository data
    for _, repo := range repos {
        fmt.Printf("Repo: %s (%d stars)\n",
            *repo.Name, *repo.StargazersCount)
    }
}

Architecture

The library is organized around a central Client type that provides access to 33 specialized service types, each handling a specific area of the GitHub API:

  • Client - Central coordinator for all API requests
  • Services - Domain-specific services (Repositories, Issues, Actions, etc.)
  • Types - Strongly-typed structs for all requests and responses
  • Utilities - Helper functions for common patterns

Key Statistics

  • Total Types: 991
  • API Services: 33
  • Total Methods: 5,077
  • Webhook Event Types: 73

Capabilities

Client and Core Functionality

Create and configure GitHub API clients, handle authentication, manage rate limits, and perform core API operations.

// Create a new GitHub API client
func NewClient(httpClient *http.Client) *Client

// Client provides access to all GitHub API services
type Client struct {
    // Base configuration fields
    BaseURL       *url.URL
    UploadURL     *url.URL
    UserAgent     string
    DisableRateLimitCheck bool
    MaxSecondaryRateLimitRetryAfterDuration time.Duration
    RateLimitRedirectionalEndpoints bool

    // Service fields for accessing API areas (33 services)
    Actions            *ActionsService
    Activity           *ActivityService
    Admin              *AdminService
    Apps               *AppsService
    Authorizations     *AuthorizationsService
    Billing            *BillingService
    Checks             *ChecksService
    Classroom          *ClassroomService
    CodeScanning       *CodeScanningService
    CodesOfConduct     *CodesOfConductService
    Codespaces         *CodespacesService
    Copilot            *CopilotService
    Dependabot         *DependabotService
    DependencyGraph    *DependencyGraphService
    Emojis             *EmojisService
    Enterprise         *EnterpriseService
    Gists              *GistsService
    Git                *GitService
    Gitignores         *GitignoresService
    Interactions       *InteractionsService
    IssueImport        *IssueImportService
    Issues             *IssuesService
    Licenses           *LicensesService
    Markdown           *MarkdownService
    Marketplace        *MarketplaceService
    Meta               *MetaService
    Migrations         *MigrationService
    Organizations      *OrganizationsService
    PrivateRegistries  *PrivateRegistriesService
    Projects           *ProjectsService
    PullRequests       *PullRequestsService
    RateLimit          *RateLimitService
    Reactions          *ReactionsService
    Repositories       *RepositoriesService
    SCIM               *SCIMService
    Search             *SearchService
    SecretScanning     *SecretScanningService
    SecurityAdvisories *SecurityAdvisoriesService
    SubIssue           *SubIssueService
    Teams              *TeamsService
    Users              *UsersService
}

// Configure authentication
func (c *Client) WithAuthToken(token string) *Client

// Configure for GitHub Enterprise
func (c *Client) WithEnterpriseURLs(baseURL, uploadURL string) (*Client, error)

// Get rate limit information
func (c *Client) RateLimits(ctx context.Context) (*RateLimits, *Response, error)

// Response includes rate limit info with every API call
type Response struct {
    *http.Response
    Rate             Rate
    TokenExpiration  time.Time
    NextPage         int
    PrevPage         int
    FirstPage        int
    LastPage         int
}

Client and Core Functionality

Repositories

Comprehensive repository management including creation, configuration, content operations, branches, releases, webhooks, and security settings. The RepositoriesService provides 221 methods covering all repository-related operations.

type RepositoriesService struct {}

// Get repository information
func (s *RepositoriesService) Get(ctx context.Context, owner, repo string) (*Repository, *Response, error)

// List repositories
func (s *RepositoriesService) List(ctx context.Context, user string, opts *RepositoryListOptions) ([]*Repository, *Response, error)
func (s *RepositoriesService) ListByOrg(ctx context.Context, org string, opts *RepositoryListByOrgOptions) ([]*Repository, *Response, error)
func (s *RepositoriesService) ListByAuthenticatedUser(ctx context.Context, opts *RepositoryListByAuthenticatedUserOptions) ([]*Repository, *Response, error)

// Create and manage repositories
func (s *RepositoriesService) Create(ctx context.Context, org string, repo *Repository) (*Repository, *Response, error)
func (s *RepositoriesService) Edit(ctx context.Context, owner, repo string, repository *Repository) (*Repository, *Response, error)
func (s *RepositoriesService) Delete(ctx context.Context, owner, repo string) (*Response, error)

// Repository content operations
func (s *RepositoriesService) GetContents(ctx context.Context, owner, repo, path string, opts *RepositoryContentGetOptions) (*RepositoryContent, []*RepositoryContent, *Response, error)
func (s *RepositoriesService) CreateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error)
func (s *RepositoriesService) UpdateFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error)
func (s *RepositoriesService) DeleteFile(ctx context.Context, owner, repo, path string, opts *RepositoryContentFileOptions) (*RepositoryContentResponse, *Response, error)

type Repository struct {
    ID               *int64
    NodeID           *string
    Owner            *User
    Name             *string
    FullName         *string
    Description      *string
    Homepage         *string
    DefaultBranch    *string
    CreatedAt        *Timestamp
    PushedAt         *Timestamp
    UpdatedAt        *Timestamp
    Size             *int
    StargazersCount  *int
    WatchersCount    *int
    ForksCount       *int
    Language         *string
    Private          *bool
    Fork             *bool
    Archived         *bool
    Disabled         *bool
    Visibility       *string
    Permissions      map[string]bool
    // ... 50+ more fields
}

Repositories

GitHub Actions

Manage GitHub Actions workflows, runs, artifacts, secrets, and runner groups. The ActionsService provides 167 methods for comprehensive Actions management.

type ActionsService struct {}

// Workflow operations
func (s *ActionsService) ListWorkflows(ctx context.Context, owner, repo string, opts *ListOptions) (*Workflows, *Response, error)
func (s *ActionsService) GetWorkflowByID(ctx context.Context, owner, repo string, workflowID int64) (*Workflow, *Response, error)
func (s *ActionsService) CreateWorkflowDispatchEventByID(ctx context.Context, owner, repo string, workflowID int64, event CreateWorkflowDispatchEventRequest) (*Response, error)

// Workflow run operations
func (s *ActionsService) ListWorkflowRunsByID(ctx context.Context, owner, repo string, workflowID int64, opts *ListWorkflowRunsOptions) (*WorkflowRuns, *Response, error)
func (s *ActionsService) GetWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*WorkflowRun, *Response, error)
func (s *ActionsService) RerunWorkflowByID(ctx context.Context, owner, repo string, runID int64) (*Response, error)
func (s *ActionsService) CancelWorkflowRunByID(ctx context.Context, owner, repo string, runID int64) (*Response, error)

// Artifact operations
func (s *ActionsService) ListArtifacts(ctx context.Context, owner, repo string, opts *ListOptions) (*ArtifactList, *Response, error)
func (s *ActionsService) GetArtifact(ctx context.Context, owner, repo string, artifactID int64) (*Artifact, *Response, error)
func (s *ActionsService) DownloadArtifact(ctx context.Context, owner, repo string, artifactID int64, maxRedirects int) (*url.URL, *Response, error)

// Secrets management
func (s *ActionsService) GetRepoSecret(ctx context.Context, owner, repo, name string) (*Secret, *Response, error)
func (s *ActionsService) CreateOrUpdateRepoSecret(ctx context.Context, owner, repo string, eSecret *EncryptedSecret) (*Response, error)
func (s *ActionsService) DeleteRepoSecret(ctx context.Context, owner, repo, name string) (*Response, error)

type Workflow struct {
    ID        *int64
    NodeID    *string
    Name      *string
    Path      *string
    State     *string
    CreatedAt *Timestamp
    UpdatedAt *Timestamp
    BadgeURL  *string
}

type WorkflowRun struct {
    ID             *int64
    Name           *string
    NodeID         *string
    HeadBranch     *string
    HeadSHA        *string
    RunNumber      *int
    Event          *string
    Status         *string
    Conclusion     *string
    WorkflowID     *int64
    URL            *string
    CreatedAt      *Timestamp
    UpdatedAt      *Timestamp
    // ... more fields
}

GitHub Actions

Issues and Pull Requests

Create, manage, and interact with issues and pull requests including comments, labels, milestones, assignees, and reviews.

type IssuesService struct {}

// Issue operations
func (s *IssuesService) Get(ctx context.Context, owner, repo string, number int) (*Issue, *Response, error)
func (s *IssuesService) Create(ctx context.Context, owner, repo string, issue *IssueRequest) (*Issue, *Response, error)
func (s *IssuesService) Edit(ctx context.Context, owner, repo string, number int, issue *IssueRequest) (*Issue, *Response, error)
func (s *IssuesService) List(ctx context.Context, all bool, opts *IssueListOptions) ([]*Issue, *Response, error)
func (s *IssuesService) ListByRepo(ctx context.Context, owner, repo string, opts *IssueListByRepoOptions) ([]*Issue, *Response, error)

// Comments
func (s *IssuesService) CreateComment(ctx context.Context, owner, repo string, number int, comment *IssueComment) (*IssueComment, *Response, error)
func (s *IssuesService) ListComments(ctx context.Context, owner, repo string, number int, opts *IssueListCommentsOptions) ([]*IssueComment, *Response, error)

// Labels
func (s *IssuesService) AddLabelsToIssue(ctx context.Context, owner, repo string, number int, labels []string) ([]*Label, *Response, error)
func (s *IssuesService) RemoveLabelForIssue(ctx context.Context, owner, repo string, number int, label string) (*Response, error)

type PullRequestsService struct {}

// Pull request operations
func (s *PullRequestsService) Get(ctx context.Context, owner, repo string, number int) (*PullRequest, *Response, error)
func (s *PullRequestsService) Create(ctx context.Context, owner, repo string, pull *NewPullRequest) (*PullRequest, *Response, error)
func (s *PullRequestsService) Edit(ctx context.Context, owner, repo string, number int, pull *PullRequest) (*PullRequest, *Response, error)
func (s *PullRequestsService) List(ctx context.Context, owner, repo string, opts *PullRequestListOptions) ([]*PullRequest, *Response, error)
func (s *PullRequestsService) Merge(ctx context.Context, owner, repo string, number int, commitMessage string, opts *PullRequestOptions) (*PullRequestMergeResult, *Response, error)

// Pull request reviews
func (s *PullRequestsService) ListReviews(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*PullRequestReview, *Response, error)
func (s *PullRequestsService) CreateReview(ctx context.Context, owner, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error)
func (s *PullRequestsService) SubmitReview(ctx context.Context, owner, repo string, number int, reviewID int64, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error)

type Issue struct {
    ID                *int64
    Number            *int
    State             *string
    Title             *string
    Body              *string
    User              *User
    Labels            []*Label
    Assignee          *User
    Assignees         []*User
    Comments          *int
    ClosedAt          *time.Time
    CreatedAt         *time.Time
    UpdatedAt         *time.Time
    Milestone         *Milestone
    Reactions         *Reactions
    // ... more fields
}

type PullRequest struct {
    ID                  *int64
    Number              *int
    State               *string
    Title               *string
    Body                *string
    User                *User
    Head                *PullRequestBranch
    Base                *PullRequestBranch
    Merged              *bool
    MergedAt            *Timestamp
    MergedBy            *User
    Comments            *int
    Commits             *int
    Additions           *int
    Deletions           *int
    ChangedFiles        *int
    Draft               *bool
    // ... more fields
}

Issues and Pull Requests

Organizations

Manage organizations, members, teams, settings, and organization-level resources.

type OrganizationsService struct {}

// Organization operations
func (s *OrganizationsService) Get(ctx context.Context, org string) (*Organization, *Response, error)
func (s *OrganizationsService) List(ctx context.Context, user string, opts *ListOptions) ([]*Organization, *Response, error)
func (s *OrganizationsService) Edit(ctx context.Context, name string, org *Organization) (*Organization, *Response, error)

// Member operations
func (s *OrganizationsService) ListMembers(ctx context.Context, org string, opts *ListMembersOptions) ([]*User, *Response, error)
func (s *OrganizationsService) IsMember(ctx context.Context, org, user string) (bool, *Response, error)
func (s *OrganizationsService) RemoveMember(ctx context.Context, org, user string) (*Response, error)

// Organization settings
func (s *OrganizationsService) GetOrgMembership(ctx context.Context, user, org string) (*Membership, *Response, error)
func (s *OrganizationsService) EditOrgMembership(ctx context.Context, user, org string, membership *Membership) (*Membership, *Response, error)

type Organization struct {
    Login                       *string
    ID                          *int64
    NodeID                      *string
    AvatarURL                   *string
    Name                        *string
    Company                     *string
    Blog                        *string
    Location                    *string
    Email                       *string
    Description                 *string
    PublicRepos                 *int
    PublicGists                 *int
    Followers                   *int
    Following                   *int
    CreatedAt                   *Timestamp
    UpdatedAt                   *Timestamp
    TotalPrivateRepos           *int
    OwnedPrivateRepos           *int
    PrivateGists                *int
    DiskUsage                   *int
    Collaborators               *int
    BillingEmail                *string
    Type                        *string
    Plan                        *Plan
    TwoFactorRequirementEnabled *bool
    // ... more fields
}

Organizations

Users

Access user profiles, repositories, followers, authentication, and user-related data.

type UsersService struct {}

// Get user information
func (s *UsersService) Get(ctx context.Context, user string) (*User, *Response, error)
func (s *UsersService) GetByID(ctx context.Context, id int64) (*User, *Response, error)

// List users
func (s *UsersService) ListAll(ctx context.Context, opts *UserListOptions) ([]*User, *Response, error)

// Followers and following
func (s *UsersService) ListFollowers(ctx context.Context, user string, opts *ListOptions) ([]*User, *Response, error)
func (s *UsersService) ListFollowing(ctx context.Context, user string, opts *ListOptions) ([]*User, *Response, error)
func (s *UsersService) IsFollowing(ctx context.Context, user, target string) (bool, *Response, error)

// Authenticated user operations
func (s *UsersService) GetAuthenticated(ctx context.Context) (*User, *Response, error)
func (s *UsersService) Edit(ctx context.Context, user *User) (*User, *Response, error)

// SSH keys
func (s *UsersService) ListKeys(ctx context.Context, user string, opts *ListOptions) ([]*Key, *Response, error)
func (s *UsersService) GetKey(ctx context.Context, id int64) (*Key, *Response, error)
func (s *UsersService) CreateKey(ctx context.Context, key *Key) (*Key, *Response, error)

type User struct {
    Login                   *string
    ID                      *int64
    NodeID                  *string
    AvatarURL               *string
    Name                    *string
    Company                 *string
    Blog                    *string
    Location                *string
    Email                   *string
    Hireable                *bool
    Bio                     *string
    TwitterUsername         *string
    PublicRepos             *int
    PublicGists             *int
    Followers               *int
    Following               *int
    CreatedAt               *Timestamp
    UpdatedAt               *Timestamp
    SuspendedAt             *Timestamp
    Type                    *string
    SiteAdmin               *bool
    // ... more fields
}

Users

Teams

Manage organization teams, members, repositories, and permissions.

type TeamsService struct {}

// Team operations
func (s *TeamsService) GetTeamByID(ctx context.Context, orgID, teamID int64) (*Team, *Response, error)
func (s *TeamsService) GetTeamBySlug(ctx context.Context, org, slug string) (*Team, *Response, error)
func (s *TeamsService) ListTeams(ctx context.Context, org string, opts *ListOptions) ([]*Team, *Response, error)
func (s *TeamsService) CreateTeam(ctx context.Context, org string, team NewTeam) (*Team, *Response, error)
func (s *TeamsService) EditTeamByID(ctx context.Context, orgID, teamID int64, team NewTeam, removeParent bool) (*Team, *Response, error)
func (s *TeamsService) DeleteTeamByID(ctx context.Context, orgID, teamID int64) (*Response, error)

// Team members
func (s *TeamsService) ListTeamMembersByID(ctx context.Context, orgID, teamID int64, opts *TeamListTeamMembersOptions) ([]*User, *Response, error)
func (s *TeamsService) GetTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string) (*Membership, *Response, error)
func (s *TeamsService) AddTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string, opts *TeamAddTeamMembershipOptions) (*Membership, *Response, error)
func (s *TeamsService) RemoveTeamMembershipByID(ctx context.Context, orgID, teamID int64, user string) (*Response, error)

// Team repositories
func (s *TeamsService) ListTeamReposByID(ctx context.Context, orgID, teamID int64, opts *ListOptions) ([]*Repository, *Response, error)
func (s *TeamsService) AddTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string, opts *TeamAddTeamRepoOptions) (*Response, error)
func (s *TeamsService) RemoveTeamRepoByID(ctx context.Context, orgID, teamID int64, owner, repo string) (*Response, error)

type Team struct {
    ID              *int64
    NodeID          *string
    Name            *string
    Description     *string
    URL             *string
    Slug            *string
    Permission      *string
    Privacy         *string
    MembersCount    *int
    ReposCount      *int
    Organization    *Organization
    Parent          *Team
    // ... more fields
}

Teams

Git Data

Low-level Git operations including blobs, commits, references, tags, and trees.

type GitService struct {}

// Blob operations
func (s *GitService) GetBlob(ctx context.Context, owner, repo, sha string) (*Blob, *Response, error)
func (s *GitService) CreateBlob(ctx context.Context, owner, repo string, blob *Blob) (*Blob, *Response, error)

// Commit operations
func (s *GitService) GetCommit(ctx context.Context, owner, repo, sha string) (*Commit, *Response, error)
func (s *GitService) CreateCommit(ctx context.Context, owner, repo string, commit *Commit, opts *CreateCommitOptions) (*Commit, *Response, error)

// Reference operations
func (s *GitService) GetRef(ctx context.Context, owner, repo, ref string) (*Reference, *Response, error)
func (s *GitService) ListMatchingRefs(ctx context.Context, owner, repo string, opts *ReferenceListOptions) ([]*Reference, *Response, error)
func (s *GitService) CreateRef(ctx context.Context, owner, repo string, ref *Reference) (*Reference, *Response, error)
func (s *GitService) UpdateRef(ctx context.Context, owner, repo string, ref *Reference, force bool) (*Reference, *Response, error)
func (s *GitService) DeleteRef(ctx context.Context, owner, repo, ref string) (*Response, error)

// Tag operations
func (s *GitService) GetTag(ctx context.Context, owner, repo, sha string) (*Tag, *Response, error)
func (s *GitService) CreateTag(ctx context.Context, owner, repo string, tag *Tag) (*Tag, *Response, error)

// Tree operations
func (s *GitService) GetTree(ctx context.Context, owner, repo, sha string, recursive bool) (*Tree, *Response, error)
func (s *GitService) CreateTree(ctx context.Context, owner, repo string, baseTree string, entries []*TreeEntry) (*Tree, *Response, error)

type Commit struct {
    SHA       *string
    Author    *CommitAuthor
    Committer *CommitAuthor
    Message   *string
    Tree      *Tree
    Parents   []*Commit
    // ... more fields
}

type Reference struct {
    Ref    *string
    URL    *string
    Object *GitObject
    NodeID *string
}

type Tree struct {
    SHA     *string
    Entries []*TreeEntry
    // ... more fields
}

Git Data

GitHub Apps

Manage GitHub Apps, installations, and app-specific operations.

type AppsService struct {}

// App operations
func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response, error)
func (s *AppsService) GetAuthenticated(ctx context.Context) (*App, *Response, error)

// Installation operations
func (s *AppsService) ListInstallations(ctx context.Context, opts *ListOptions) ([]*Installation, *Response, error)
func (s *AppsService) GetInstallation(ctx context.Context, id int64) (*Installation, *Response, error)
func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64, opts *InstallationTokenOptions) (*InstallationToken, *Response, error)
func (s *AppsService) DeleteInstallation(ctx context.Context, id int64) (*Response, error)

// Repository operations for installations
func (s *AppsService) ListRepos(ctx context.Context, opts *ListOptions) ([]*Repository, *Response, error)
func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opts *ListOptions) ([]*Repository, *Response, error)
func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (*Repository, *Response, error)
func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64) (*Response, error)

type App struct {
    ID          *int64
    Slug        *string
    NodeID      *string
    Owner       *User
    Name        *string
    Description *string
    ExternalURL *string
    HTMLURL     *string
    CreatedAt   *Timestamp
    UpdatedAt   *Timestamp
    Permissions *InstallationPermissions
    Events      []string
    // ... more fields
}

type Installation struct {
    ID                  *int64
    AppID               *int64
    AppSlug             *string
    TargetID            *int64
    Account             *User
    AccessTokensURL     *string
    RepositoriesURL     *string
    HTMLURL             *string
    TargetType          *string
    SingleFileName      *string
    RepositorySelection *string
    Events              []string
    Permissions         *InstallationPermissions
    CreatedAt           *Timestamp
    UpdatedAt           *Timestamp
    // ... more fields
}

GitHub Apps

Checks

Create and manage check runs and check suites for continuous integration.

type ChecksService struct {}

// Check run operations
func (s *ChecksService) GetCheckRun(ctx context.Context, owner, repo string, checkRunID int64) (*CheckRun, *Response, error)
func (s *ChecksService) CreateCheckRun(ctx context.Context, owner, repo string, opts CreateCheckRunOptions) (*CheckRun, *Response, error)
func (s *ChecksService) UpdateCheckRun(ctx context.Context, owner, repo string, checkRunID int64, opts UpdateCheckRunOptions) (*CheckRun, *Response, error)
func (s *ChecksService) ListCheckRunAnnotations(ctx context.Context, owner, repo string, checkRunID int64, opts *ListOptions) ([]*CheckRunAnnotation, *Response, error)
func (s *ChecksService) ListCheckRunsForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckRunsOptions) (*ListCheckRunsResults, *Response, error)

// Check suite operations
func (s *ChecksService) GetCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*CheckSuite, *Response, error)
func (s *ChecksService) CreateCheckSuite(ctx context.Context, owner, repo string, opts CreateCheckSuiteOptions) (*CheckSuite, *Response, error)
func (s *ChecksService) ReRequestCheckSuite(ctx context.Context, owner, repo string, checkSuiteID int64) (*Response, error)
func (s *ChecksService) ListCheckSuitesForRef(ctx context.Context, owner, repo, ref string, opts *ListCheckSuiteOptions) (*ListCheckSuiteResults, *Response, error)

type CheckRun struct {
    ID          *int64
    NodeID      *string
    HeadSHA     *string
    ExternalID  *string
    URL         *string
    HTMLURL     *string
    DetailsURL  *string
    Status      *string
    Conclusion  *string
    StartedAt   *Timestamp
    CompletedAt *Timestamp
    Output      *CheckRunOutput
    Name        *string
    CheckSuite  *CheckSuite
    App         *App
    // ... more fields
}

type CheckSuite struct {
    ID           *int64
    NodeID       *string
    HeadBranch   *string
    HeadSHA      *string
    URL          *string
    BeforeSHA    *string
    AfterSHA     *string
    Status       *string
    Conclusion   *string
    App          *App
    Repository   *Repository
    CreatedAt    *Timestamp
    UpdatedAt    *Timestamp
    // ... more fields
}

Checks

Enterprise

Manage GitHub Enterprise settings, users, and organization operations.

type EnterpriseService struct {}

// Enterprise operations
func (s *EnterpriseService) GetAuditLog(ctx context.Context, enterprise string, opts *GetAuditLogOptions) ([]*AuditEntry, *Response, error)

// SCIM operations
func (s *EnterpriseService) GetEnterpriseUserByID(ctx context.Context, enterprise string, userID string) (*EnterpriseUser, *Response, error)
func (s *EnterpriseService) UpdateEnterpriseUserByID(ctx context.Context, enterprise string, userID string, user *EnterpriseUser) (*EnterpriseUser, *Response, error)
func (s *EnterpriseService) CreateEnterpriseUser(ctx context.Context, enterprise string, user *EnterpriseUser) (*EnterpriseUser, *Response, error)
func (s *EnterpriseService) DeleteEnterpriseUserByID(ctx context.Context, enterprise string, userID string) (*Response, error)

type EnterpriseUser struct {
    Schemas      []string
    ID           string
    ExternalID   string
    UserName     string
    Name         EnterpriseUserName
    Emails       []EnterpriseUserEmail
    Groups       []EnterpriseUserGroup
    Active       bool
    // ... more fields
}

Enterprise

Additional Services

The library provides many more specialized services:

  • Activity - Events, notifications, starring, and watching
  • Billing - Organization and user billing information
  • Code Scanning - Code scanning alerts and analyses
  • Codespaces - Codespace management
  • Copilot - GitHub Copilot settings and usage
  • Dependabot - Dependabot alerts and secrets
  • Dependency Graph - Repository dependency information
  • Gists - Gist creation and management
  • Licenses - Repository and GitHub licenses
  • Marketplace - GitHub Marketplace operations
  • Migrations - Repository migrations
  • Packages - GitHub Packages management
  • Projects - Project boards and cards
  • Reactions - Emoji reactions on issues, PRs, comments
  • Search - Search repositories, code, issues, users
  • Secret Scanning - Secret scanning alerts
  • Security Advisories - Repository security advisories
  • Webhooks - Webhook configuration and delivery

Additional Services

Common Patterns

Key patterns for effective use of the library.

// Pagination with ListOptions
type ListOptions struct {
    Page    int
    PerPage int  // Max 100
}

// Use Response.NextPage for pagination
repos, resp, _ := client.Repositories.List(ctx, "user", &github.RepositoryListOptions{
    ListOptions: github.ListOptions{Page: 1, PerPage: 30},
})
if resp.NextPage != 0 {
    // More pages available
}

// Helper function for pointer values
repo := &github.Repository{
    Name:        github.Ptr("repo-name"),
    Description: github.Ptr("A description"),
    Private:     github.Ptr(false),
}

// Error handling with type assertions
if _, err := client.Repositories.Get(ctx, "owner", "repo"); err != nil {
    if rateLimitErr, ok := err.(*github.RateLimitError); ok {
        fmt.Printf("Rate limited until %v\n", rateLimitErr.Rate.Reset)
    } else if abuseErr, ok := err.(*github.AbuseRateLimitError); ok {
        fmt.Printf("Secondary rate limit: retry after %v\n", abuseErr.RetryAfter)
    }
}

// Context usage for timeouts and cancellation
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
user, _, err := client.Users.Get(ctx, "octocat")

Common Types

Core types used throughout the library.

// Timestamp wraps time.Time for JSON marshaling
type Timestamp struct {
    time.Time
}

// User represents a GitHub user
type User struct {
    Login     *string
    ID        *int64
    NodeID    *string
    AvatarURL *string
    Name      *string
    Email     *string
    // ... more fields
}

// Rate represents API rate limit information
type Rate struct {
    Limit     int
    Remaining int
    Reset     Timestamp
}

// RateLimits contains all rate limit categories
type RateLimits struct {
    Core                      *Rate
    Search                    *Rate
    GraphQL                   *Rate
    IntegrationManifest       *Rate
    SourceImport              *Rate
    CodeScanningUpload        *Rate
    ActionsRunnerRegistration *Rate
    SCIM                      *Rate
    DependencySnapshots       *Rate
    CodeSearch                *Rate
    AuditLog                  *Rate
}

// Error types
type ErrorResponse struct {
    Response *http.Response
    Message  string
    Errors   []Error
}

type RateLimitError struct {
    Rate     Rate
    Response *http.Response
    Message  string
}

type AbuseRateLimitError struct {
    Response   *http.Response
    Message    string
    RetryAfter *time.Duration
}

type TwoFactorAuthError ErrorResponse

type AcceptedError struct{}

Webhook Events

The library provides types for all 73 GitHub webhook event types. Parse webhook payloads using:

// Parse webhook payload
func ParseWebHook(messageType string, payload []byte) (interface{}, error)

// Validate webhook signature
func ValidateSignature(signature string, payload, secretToken []byte) error

// Validate webhook request and return payload
func ValidatePayload(r *http.Request, secretToken []byte) ([]byte, error)

// Get webhook event type from request
func WebHookType(r *http.Request) string

// Get delivery ID from request
func DeliveryID(r *http.Request) string

Example webhook event types:

  • PushEvent - Repository push
  • PullRequestEvent - Pull request activity
  • IssuesEvent - Issue activity
  • IssueCommentEvent - Issue comment activity
  • WorkflowRunEvent - GitHub Actions workflow run
  • ReleaseEvent - Release published
  • DeploymentEvent - Deployment created
  • And 66 more event types

Helper Functions

Utility functions for common operations.

// Create pointer to value (preferred method)
func Ptr[T any](v T) *T

// Legacy pointer helpers (deprecated, use Ptr)
func Bool(v bool) *bool
func Int(v int) *int
func Int64(v int64) *int64
func String(v string) *string

// String representation of types
func Stringify(message interface{}) string

Error Handling

The library provides specialized error types for different scenarios:

  • ErrorResponse - Standard API error with details
  • RateLimitError - Primary rate limit exceeded (check Rate.Reset)
  • AbuseRateLimitError - Secondary rate limit (check RetryAfter)
  • TwoFactorAuthError - Two-factor authentication required
  • AcceptedError - Request accepted but processing asynchronously (202 status)

All errors can be type-asserted to access additional context.