gogithub

package module
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 1 Imported by: 0

README

GoGitHub

Go CI Go Lint Go SAST Docs Docs Visualization License

Documentation | API Reference

gogithub is a high-level Go module for interacting with the GitHub API. It wraps go-github with convenience functions organized by operation type.

Installation

go get github.com/grokify/gogithub

The clientv1 package provides a stable, version-isolated wrapper around go-github. Use it to avoid breaking changes when go-github updates its major version (v88 → v89 → v90...).

package main

import (
    "context"
    "fmt"

    "github.com/grokify/gogithub"
    "github.com/grokify/gogithub/clientv1"
)

func main() {
    ctx := context.Background()
    client, err := clientv1.NewClient(ctx, "your-github-token")
    if err != nil {
        panic(err)
    }

    // All methods return stable gogithub.* types
    user, _ := client.GetAuthenticatedUser(ctx)  // *gogithub.User
    repos, _ := client.ListUserRepos(ctx, user.Login)  // []*gogithub.Repository
    sha, _ := client.GetBranchSHA(ctx, "owner", "repo", "main")  // string
    content, _ := client.GetFileContent(ctx, "owner", "repo", "README.md", nil)  // []byte
    
    fmt.Printf("Found %d repos for %s\n", len(repos), user.Login)
}

Benefits:

  • Types like gogithub.User and gogithub.Repository won't change
  • When go-github updates, only gogithub needs updating—your code stays the same
  • Single import pattern: gogithub for types, clientv1 for the client

What does "v1" mean? The "1" is the API version of the wrapper interface, not the go-github version. Consumers stay on clientv1 indefinitely while gogithub internally updates go-github (v88 → v89 → v90...). If we ever need breaking changes to the wrapper's interface, we'd create clientv2.

See the Version-Isolated Client Guide for full documentation.

Directory Structure

The package is organized into subdirectories by operation type for scalability:

gogithub/
├── types.go              # Stable types (User, Repository, etc.)
├── gogithub.go           # Client factory, backward-compatible re-exports
├── clientv1/             # Version-isolated client wrapper (RECOMMENDED)
│   ├── client.go         # Client interface
│   ├── client_impl.go    # Implementation wrapping go-github
│   ├── convert.go        # Type converters
│   └── doc.go            # Package documentation
├── auth/                 # Authentication utilities
│   └── auth.go           # NewGitHubClient, GetAuthenticatedUser
├── config/               # Configuration utilities
│   └── config.go         # Config struct, FromEnv, GitHub Enterprise support
├── errors/               # Error types and translation
│   └── errors.go         # APIError, Translate, IsNotFound, IsRateLimited
├── graphql/              # GraphQL API for contribution statistics
│   ├── client.go         # NewClient, NewEnterpriseClient
│   ├── contributions.go  # GetContributionStats, GetContributionStatsMultiYear
│   └── commitstats.go    # GetCommitStats, GetCommitStatsByVisibility
├── profile/              # User profile aggregation
│   ├── profile.go        # UserProfile, GetUserProfile
│   ├── calendar.go       # ContributionCalendar, streaks
│   ├── activity.go       # MonthlyActivity, ActivityTimeline, MonthlyStats
│   ├── monthly_output.go # WriteMonthlyFile, WriteMonthlyFiles
│   ├── stats_report.go   # StatsReport, BuildStatsReport, LoadMonthlyFiles
│   ├── stats_render.go   # RenderToMarkdown, RenderToHTML, RenderToText
│   ├── readme/           # README.md generation
│   │   ├── readme.go     # Generate, DefaultConfig
│   │   ├── heatmap.go    # RenderHeatmap (Unicode contribution calendar)
│   │   └── template.go   # Template helpers
│   └── svg/              # SVG visualization generation
│       ├── card.go       # GenerateStatsCard
│       ├── stats.go      # Stats rendering
│       ├── theme.go      # Theme definitions (dark, dracula, nord, etc.)
│       ├── icons.go      # Metric icons
│       └── chart/        # Chart primitives
│           ├── bar.go    # Bar chart rendering
│           └── types.go  # Chart data types
├── pathutil/             # Path validation and normalization
│   └── pathutil.go       # Validate, Normalize, Join, Split
├── search/               # Search API operations
│   ├── search.go         # SearchIssues, SearchIssuesAll
│   ├── query.go          # Query builder, parameter constants
│   └── issues.go         # Issues type, table generation
├── repo/                 # Repository operations
│   ├── fork.go           # EnsureFork, GetDefaultBranch
│   ├── branch.go         # CreateBranch, GetBranchSHA, DeleteBranch
│   ├── commit.go         # CreateCommit (Git tree API), ReadLocalFiles
│   ├── list.go           # ListOrgRepos, ListUserRepos, GetRepo
│   ├── contributors.go   # ListContributorStats, GetContributorSummary
│   └── batch.go          # Batch for atomic multi-file commits
├── pr/                   # Pull request operations
│   └── pullrequest.go    # CreatePR, GetPR, ListPRs, MergePR, ApprovePR, IsMergeable
├── release/              # Release operations
│   └── release.go        # ListReleases, GetLatestRelease, CreateRelease, DeleteRelease
├── checks/               # Check runs operations
│   └── checks.go         # ListCheckRuns, WaitForChecks, AllChecksPassed
├── sarif/                # SARIF upload for GitHub Code Scanning
│   └── sarif.go          # Upload, UploadFile, GetUploadStatus, WaitForProcessing
├── tag/                  # Git tag operations
│   └── tag.go            # ListTags, CreateTag, GetTagSHA, TagExists
├── cliutil/              # CLI utilities
│   └── status.go         # Git status helpers
├── cmd/                  # CLI tools
│   ├── gogithub/         # Main CLI (profile, search-prs, stats-report commands)
│   └── searchuserpr/     # Search user PRs example
└── web/                  # Profile Viewer web application
    └── src/              # TypeScript source (Vite, Chart.js)

Usage

package main

import (
    "context"
    "fmt"

    "github.com/grokify/gogithub"
    "github.com/grokify/gogithub/clientv1"
)

func main() {
    ctx := context.Background()
    client, err := clientv1.NewClient(ctx, "your-github-token")
    if err != nil {
        panic(err)
    }

    // All methods return stable gogithub.* types
    user, _ := client.GetAuthenticatedUser(ctx)
    repos, _ := client.ListUserRepos(ctx, user.Login)
    
    for _, repo := range repos {
        fmt.Printf("- %s (%s)\n", repo.FullName, repo.Language)
    }
}
Operation Packages (search, repo, pr, checks, tag, release, sarif)

These packages take a clientv1.Client, so they stay version-isolated just like the client itself.

package main

import (
    "context"
    "fmt"

    "github.com/grokify/gogithub/clientv1"
    "github.com/grokify/gogithub/search"
)

func main() {
    ctx := context.Background()

    client, err := clientv1.NewClient(ctx, "your-github-token")
    if err != nil {
        panic(err)
    }

    // Search for open pull requests
    c := search.NewClient(client)
    issues, err := c.SearchIssuesAll(ctx, search.Query{
        search.ParamUser:  "grokify",
        search.ParamState: search.ParamStateValueOpen,
        search.ParamIs:    search.ParamIsValuePR,
    }, nil)
    if err != nil {
        panic(err)
    }

    fmt.Printf("Found %d open PRs\n", len(issues))
}
Creating a Pull Request
package main

import (
    "context"
    "fmt"

    "github.com/grokify/gogithub/clientv1"
    "github.com/grokify/gogithub/pr"
    "github.com/grokify/gogithub/repo"
)

func main() {
    ctx := context.Background()
    client, err := clientv1.NewClient(ctx, "your-github-token")
    if err != nil {
        panic(err)
    }

    // Get branch SHA
    sha, err := repo.GetBranchSHA(ctx, client, "owner", "repo", "main")
    if err != nil {
        panic(err)
    }

    // Create a new branch
    err = repo.CreateBranch(ctx, client, "owner", "repo", "feature-branch", sha)
    if err != nil {
        panic(err)
    }

    // Create files and commit
    files := []repo.FileContent{
        {Path: "README.md", Content: []byte("# Hello")},
    }
    _, err = repo.CreateCommit(ctx, client, "owner", "repo", "feature-branch", "Add README", files)
    if err != nil {
        panic(err)
    }

    // Create pull request
    pullRequest, err := pr.CreatePR(ctx, client, "upstream-owner", "upstream-repo",
        "fork-owner", "feature-branch", "main", "My PR Title", "PR description")
    if err != nil {
        panic(err)
    }

    fmt.Printf("PR created: %s\n", pullRequest.HTMLURL)
}
Waiting for CI Checks
package main

import (
    "context"
    "fmt"
    "time"

    "github.com/grokify/gogithub/checks"
    "github.com/grokify/gogithub/clientv1"
)

func main() {
    ctx := context.Background()
    client, err := clientv1.NewClient(ctx, "your-github-token")
    if err != nil {
        panic(err)
    }

    // Wait for all checks to complete (with 10 minute timeout)
    checkRuns, allPassed, err := checks.WaitForChecks(ctx, client, "owner", "repo", "commit-sha",
        10*time.Minute, 30*time.Second)
    if err != nil {
        panic(err)
    }

    // Get aggregate status
    status := checks.GetChecksStatus(checkRuns)
    fmt.Printf("Checks: %d passed, %d failed, %d pending\n",
        status.Passed, status.Failed, status.Pending)

    if allPassed {
        fmt.Println("All checks passed!")
    }
}
Creating Tags and Releases
package main

import (
    "context"
    "fmt"

    "github.com/grokify/gogithub/clientv1"
    "github.com/grokify/gogithub/release"
    "github.com/grokify/gogithub/tag"
)

func main() {
    ctx := context.Background()
    client, err := clientv1.NewClient(ctx, "your-github-token")
    if err != nil {
        panic(err)
    }

    // Create an annotated tag
    err = tag.CreateTag(ctx, client, "owner", "repo", "v1.0.0", "commit-sha", "Release v1.0.0")
    if err != nil {
        panic(err)
    }

    // Create a release
    rel, err := release.CreateReleaseSimple(ctx, client, "owner", "repo",
        "v1.0.0",           // tag name
        "Version 1.0.0",    // release name
        "Release notes...", // body
        false,              // draft
        false,              // prerelease
        true,               // generate notes
    )
    if err != nil {
        panic(err)
    }

    fmt.Printf("Release created: %s\n", rel.HTMLURL)
}
User Profile Statistics

Get comprehensive contribution statistics similar to GitHub profile pages. See the full documentation for details.

package main

import (
    "context"
    "fmt"
    "time"

    "github.com/grokify/gogithub/clientv1"
    "github.com/grokify/gogithub/graphql"
    "github.com/grokify/gogithub/profile"
)

func main() {
    ctx := context.Background()
    token := "your-github-token"

    restClient, err := clientv1.NewClient(ctx, token)
    if err != nil {
        panic(err)
    }
    gqlClient := graphql.NewClient(ctx, token)

    // Fetch profile for last year
    from := time.Now().AddDate(-1, 0, 0)
    to := time.Now()

    p, err := profile.GetUserProfile(ctx, restClient, gqlClient, "grokify", from, to, nil)
    if err != nil {
        panic(err)
    }

    // Summary
    fmt.Println(p.Summary())
    // grokify: 150 commits (+10000/-3000) in 12 repos, 25 PRs, 10 issues, 50 reviews

    // Calendar stats
    fmt.Printf("Longest streak: %d days\n", p.Calendar.LongestStreak())

    // Monthly activity
    for _, m := range p.Activity.Months {
        if s := m.CommitSummary(); s != "" {
            fmt.Printf("%s %d: %s\n", m.MonthName(), m.Year, s)
        }
    }
}
Profile Output Formats

Generate profile visualizations in multiple formats:

# Generate all outputs
gogithub profile --user grokify --from 2024-01-01 --to 2024-12-31 \
    --output-readme README.md \
    --output-svg stats.svg --svg-theme dracula \
    --output-chart chart.svg \
    --output-chart-json chart.json
README with Contribution Heatmap

Generate a GitHub profile README with a Unicode contribution calendar:

import "github.com/grokify/gogithub/profile/readme"

config := readme.DefaultConfig()
config.ShowHeatmap = true

output, err := readme.Generate(profile, config)
SVG Stats Card

Generate embeddable stats cards with theme support:

import "github.com/grokify/gogithub/profile/svg"

// Available themes: default, dark, dracula, nord, gruvbox, solarized
card, err := svg.GenerateStatsCard(profile, svg.ThemeDracula, "My GitHub Stats")
Monthly Activity Charts

Generate charts as SVG or JSON intermediate representation:

import "github.com/grokify/gogithub/profile/svg"

// SVG chart
chartSVG, err := svg.GenerateMonthlyChart(profile.Timeline, svg.ChartOptions{
    Width:  800,
    Height: 400,
})

// JSON IR for custom rendering
chartJSON, err := svg.GenerateChartJSON(profile.Timeline)

Adding New Functionality

When adding new GitHub API functionality, follow this structure:

  1. Identify the operation category - Determine which subdirectory the functionality belongs to:

    • auth/ - Authentication, user identity
    • config/ - Configuration, environment variables, GitHub Enterprise
    • errors/ - Error types and translation utilities
    • pathutil/ - Path validation and normalization
    • search/ - Search API (issues, PRs, code, commits, etc.)
    • repo/ - Repository operations (forks, branches, commits, batch operations)
    • pr/ - Pull request operations
    • release/ - Release and asset operations
    • Create new directories for distinct API areas (e.g., issues/, actions/, gists/)
  2. Create focused files - Within each subdirectory, organize by specific functionality:

    • One file per logical grouping (e.g., fork.go, branch.go, commit.go)
    • Keep files focused and cohesive
  3. Use consistent patterns:

    • Functions take context.Context and clientv1.Client as first parameters (use client.Raw() internally only for operations clientv1.Client doesn't yet wrap)
    • Return appropriate error types with context
    • Provide both low-level functions and convenience wrappers
  4. Define custom error types when needed:

    type ForkError struct {
        Owner string
        Repo  string
        Err   error
    }
    
    func (e *ForkError) Error() string {
        return "failed to fork " + e.Owner + "/" + e.Repo + ": " + e.Err.Error()
    }
    
    func (e *ForkError) Unwrap() error {
        return e.Err
    }
    
  5. Add tests in corresponding *_test.go files

Example: Adding Gist Support
gogithub/
└── gist/
    ├── gist.go       # Create, Get, List, Update, Delete
    └── gist_test.go
// gist/gist.go
package gist

import (
    "context"

    "github.com/grokify/gogithub"
    "github.com/grokify/gogithub/clientv1"
)

func Create(ctx context.Context, client clientv1.Client, description string, public bool, files map[string]string) (*gogithub.Gist, error) {
    // Implementation, e.g. using client.Raw() until clientv1.Client wraps gist operations
}

func Get(ctx context.Context, client clientv1.Client, id string) (*gogithub.Gist, error) {
    // Implementation
}

Deprecated Functions

A few legacy functions that return go-github types directly are deprecated in favor of clientv1:

Deprecated Use instead
auth.NewGitHubClient() clientv1.NewClient()
auth.GetAuthenticatedUser() client.GetAuthenticatedUser()
auth.GetUser() client.GetUser()
config.Config.NewClient() / MustNewClient() config.Config.NewClientV1() / MustNewClientV1()

They still work — go-github upgrades are the only thing that can break them — but new code should use clientv1 so it never needs to change when go-github does.

Dependencies

License

MIT License

Documentation

Overview

Package gogithub provides a Go client for the GitHub API.

For new code, use the clientv1 package which provides stable types that won't change when go-github updates its major version:

import "github.com/grokify/gogithub/clientv1"

client, err := clientv1.NewClient(ctx, "your-token")
user, err := client.GetAuthenticatedUser(ctx)      // Returns *clientv1.User
repos, err := client.ListUserRepos(ctx, "user")    // Returns []*clientv1.Repository
sha, err := client.GetBranchSHA(ctx, "owner", "repo", "main")

Operation Packages

The following packages also accept clientv1.Client and return stable gogithub.* types, so they stay version-isolated like the client itself:

  • search: Search API (issues, PRs, code, etc.)
  • repo: Repository operations (fork, branch, commit, batch)
  • pr: Pull request operations
  • release: Release and asset operations
  • checks: Check run polling and status
  • tag: Git tag operations
  • sarif: SARIF upload for code scanning

A few legacy functions in auth and config still return go-github types directly and are deprecated (auth.NewGitHubClient, config.Config.NewClient); prefer clientv1.NewClient and config.Config.NewClientV1 instead.

Example:

package main

import (
    "context"
    "fmt"

    "github.com/grokify/gogithub/clientv1"
    "github.com/grokify/gogithub/search"
)

func main() {
    ctx := context.Background()
    client, err := clientv1.NewClient(ctx, "your-token")
    if err != nil {
        panic(err)
    }

    c := search.NewClient(client)
    issues, err := c.SearchIssuesAll(ctx, search.Query{
        search.ParamUser:  "grokify",
        search.ParamState: search.ParamStateValueOpen,
    }, nil)
    if err != nil {
        panic(err)
    }
    fmt.Printf("Found %d issues\n", len(issues))
}

Index

Constants

View Source
const (
	// BaseURLRepoAPI is the base URL for the GitHub API repository endpoints.
	BaseURLRepoAPI = "https://api.github.com/repos"
	// BaseURLRepoHTML is the base URL for GitHub repository web pages.
	BaseURLRepoHTML = "https://github.com"
)

GitHub API base URLs.

Variables

This section is empty.

Functions

This section is empty.

Types

type App added in v0.15.0

type App struct {
	ID          int64
	Slug        string
	Name        string
	Description string
	HTMLURL     string
}

App represents a GitHub App.

type Branch added in v0.15.0

type Branch struct {
	Name      string
	Protected bool
	Commit    *Commit
}

Branch represents a repository branch.

type CheckRun added in v0.15.0

type CheckRun struct {
	ID          int64
	HeadSHA     string
	Status      string // "queued", "in_progress", "completed"
	Conclusion  string // "success", "failure", "neutral", "cancelled", "skipped", "timed_out", "action_required"
	Name        string
	HTMLURL     string
	StartedAt   *time.Time
	CompletedAt *time.Time
}

CheckRun represents a GitHub Actions check run.

type CheckSuite added in v0.15.0

type CheckSuite struct {
	ID         int64
	HeadBranch string
	HeadSHA    string
	Status     string // "queued", "in_progress", "completed"
	Conclusion string // "success", "failure", "neutral", "cancelled", "skipped", "timed_out", "action_required"
	URL        string
	App        *App
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

CheckSuite represents a GitHub Actions check suite.

type CodeResult added in v0.15.0

type CodeResult struct {
	Name       string
	Path       string
	SHA        string
	HTMLURL    string
	Repository *Repository
}

CodeResult represents a single code search result.

type CodeSearchResult added in v0.15.0

type CodeSearchResult struct {
	Total             int
	IncompleteResults bool
	Items             []*CodeResult
}

CodeSearchResult represents search results for code.

type Commit added in v0.15.0

type Commit struct {
	SHA       string
	Message   string
	Author    *CommitAuthor
	Committer *CommitAuthor
	HTMLURL   string
	Tree      *GitObject // Root tree of this commit
	Parents   []CommitParent
}

Commit represents a git commit.

type CommitAuthor added in v0.15.0

type CommitAuthor struct {
	Name  string
	Email string
	Date  time.Time
}

CommitAuthor represents the author/committer of a commit.

type CommitFile added in v0.15.0

type CommitFile struct {
	SHA         string
	Filename    string
	Status      string // "added", "removed", "modified", "renamed", "copied", "changed", "unchanged"
	Additions   int
	Deletions   int
	Changes     int
	Patch       string
	BlobURL     string
	RawURL      string
	ContentsURL string
	Previous    string // Previous filename for renamed files
}

CommitFile represents a file changed in a commit.

type CommitParent added in v0.15.0

type CommitParent struct {
	SHA string
	URL string
}

CommitParent represents a parent commit reference.

type ContentOptions added in v0.15.0

type ContentOptions struct {
	Ref string // Branch, tag, or commit SHA. Empty uses default branch.
}

ContentOptions specifies options for fetching repository content.

type ContributorStats added in v0.15.0

type ContributorStats struct {
	Author *User
	Total  int
	Weeks  []WeeklyStats
}

ContributorStats represents contribution statistics for a user.

type CreateFileResult added in v0.15.0

type CreateFileResult struct {
	Content *FileContent
	Commit  *Commit
}

CreateFileResult represents the result of creating or updating a file.

type DeleteFileResult added in v0.15.0

type DeleteFileResult struct {
	Commit *Commit
}

DeleteFileResult represents the result of deleting a file.

type Event added in v0.16.0

type Event struct {
	ID        string
	Type      string
	Public    bool
	Actor     *User
	Repo      *EventRepo
	CreatedAt time.Time
}

Event represents a GitHub activity event, such as those returned by a user's public timeline (e.g., "PushEvent", "PullRequestEvent", "IssuesEvent").

type EventRepo added in v0.16.0

type EventRepo struct {
	ID   int64
	Name string // "owner/repo"
	URL  string
}

EventRepo identifies the repository an Event occurred in. It carries only the fields the GitHub Events API populates, not the full Repository.

type FileContent added in v0.15.0

type FileContent struct {
	Path        string
	Name        string
	SHA         string
	Size        int
	Type        string // "file", "dir", "symlink", "submodule"
	Content     []byte // Decoded content (for files)
	DownloadURL string
}

FileContent represents file content from a repository.

type GitObject added in v0.15.0

type GitObject struct {
	Type string // "commit", "tag", etc.
	SHA  string
	URL  string
}

GitObject represents the object a reference points to.

type Issue

type Issue struct {
	ID            int64
	Number        int
	State         string
	Title         string
	Body          string
	HTMLURL       string
	RepositoryURL string // API URL of the repository
	User          *User
	Labels        []Label
	Assignees     []*User
	Comments      int
	IsPullRequest bool // true if this issue is actually a pull request
	CreatedAt     time.Time
	UpdatedAt     time.Time
	ClosedAt      *time.Time
}

Issue represents a GitHub issue.

type IssueComment added in v0.15.0

type IssueComment struct {
	ID        int64
	User      *User
	Body      string
	HTMLURL   string
	CreatedAt time.Time
	UpdatedAt time.Time
}

IssueComment represents a comment on an issue or pull request.

type IssueSearchResult added in v0.15.0

type IssueSearchResult = SearchResult[*Issue]

IssueSearchResult is a search result containing issues.

type Label added in v0.15.0

type Label struct {
	ID          int64
	Name        string
	Description string
	Color       string
}

Label represents a GitHub label.

type MergeResult added in v0.15.0

type MergeResult struct {
	SHA     string
	Merged  bool
	Message string
}

MergeResult represents the result of merging a pull request.

type PullRequest added in v0.15.0

type PullRequest struct {
	ID        int64
	Number    int
	State     string // "open", "closed"
	Title     string
	Body      string
	HTMLURL   string
	User      *User
	Head      *PullRequestBranch
	Base      *PullRequestBranch
	Labels    []Label
	Assignees []*User
	Merged    bool
	Mergeable *bool
	Draft     bool
	Additions int
	Deletions int
	Commits   int
	CreatedAt time.Time
	UpdatedAt time.Time
	ClosedAt  *time.Time
	MergedAt  *time.Time
}

PullRequest represents a GitHub pull request.

type PullRequestBranch added in v0.15.0

type PullRequestBranch struct {
	Label string
	Ref   string
	SHA   string
	User  *User
	Repo  *Repository
}

PullRequestBranch represents the head or base branch of a PR.

type PullRequestComment added in v0.15.0

type PullRequestComment struct {
	ID        int64
	User      *User
	Body      string
	Path      string
	Line      int
	Side      string // "LEFT" or "RIGHT"
	CommitID  string
	HTMLURL   string
	CreatedAt time.Time
	UpdatedAt time.Time
}

PullRequestComment represents a comment on a pull request diff.

type PullRequestReview added in v0.15.0

type PullRequestReview struct {
	ID          int64
	User        *User
	Body        string
	State       string // "APPROVED", "CHANGES_REQUESTED", "COMMENTED", "DISMISSED", "PENDING"
	HTMLURL     string
	CommitID    string
	SubmittedAt *time.Time
}

PullRequestReview represents a review on a pull request.

type Reference added in v0.15.0

type Reference struct {
	Ref    string // e.g., "refs/heads/main"
	SHA    string // Convenience field: same as Object.SHA
	URL    string
	Object *GitObject
}

Reference represents a git reference (branch, tag).

type Release added in v0.15.0

type Release struct {
	ID              int64
	TagName         string
	TargetCommitish string
	Name            string
	Body            string
	Draft           bool
	Prerelease      bool
	HTMLURL         string
	TarballURL      string
	ZipballURL      string
	CreatedAt       time.Time
	PublishedAt     *time.Time
	Author          *User
	Assets          []ReleaseAsset
}

Release represents a GitHub release.

type ReleaseAsset added in v0.15.0

type ReleaseAsset struct {
	ID                 int64
	Name               string
	Label              string
	State              string
	ContentType        string
	Size               int
	DownloadCount      int
	BrowserDownloadURL string
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

ReleaseAsset represents an asset attached to a release.

type ReleaseAssetUpload added in v0.15.0

type ReleaseAssetUpload struct {
	Name        string
	Label       string
	ContentType string
	Content     []byte
}

ReleaseAssetUpload represents an asset being uploaded to a release.

type Repository added in v0.15.0

type Repository struct {
	ID              int64
	Owner           *User
	Name            string
	FullName        string
	Description     string
	HTMLURL         string
	CloneURL        string
	SSHURL          string
	DefaultBranch   string
	Private         bool
	Fork            bool
	Archived        bool
	Disabled        bool
	Language        string
	ForksCount      int
	StargazersCount int
	WatchersCount   int
	OpenIssuesCount int
	Size            int
	CreatedAt       time.Time
	UpdatedAt       time.Time
	PushedAt        time.Time
}

Repository represents a GitHub repository.

type SearchResult added in v0.15.0

type SearchResult[T any] struct {
	Total             int
	IncompleteResults bool
	Items             []T
}

SearchResult represents search results from the GitHub API.

type Tag added in v0.15.0

type Tag struct {
	Name   string
	Commit *Commit
	SHA    string // SHA of the tag object (for annotated) or commit (for lightweight)
}

Tag represents a git tag.

type TreeNode added in v0.15.0

type TreeNode struct {
	Path string
	Mode string // "100644" (file), "100755" (executable), "040000" (dir), "160000" (submodule), "120000" (symlink)
	Type string // "blob", "tree", "commit"
	SHA  string
	Size int
	URL  string
}

TreeNode represents a node in a git tree.

type User added in v0.15.0

type User struct {
	ID        int64
	Login     string
	Name      string
	Email     string
	AvatarURL string
	HTMLURL   string
	Type      string // "User" or "Organization"
	Bio       string
	Company   string
	Location  string
	Blog      string
	Followers int
	Following int
	CreatedAt time.Time
	UpdatedAt time.Time
}

User represents a GitHub user. This is a stable type that won't change when go-github updates its major version.

type WeeklyStats added in v0.15.0

type WeeklyStats struct {
	Week      time.Time
	Additions int
	Deletions int
	Commits   int
}

WeeklyStats represents contribution stats for a single week.

Directories

Path Synopsis
Package auth provides GitHub authentication utilities.
Package auth provides GitHub authentication utilities.
Package checks provides GitHub check runs operations.
Package checks provides GitHub check runs operations.
Package clientv1 provides a stable, version-isolated client for the GitHub API.
Package clientv1 provides a stable, version-isolated client for the GitHub API.
cmd/bulk_git_rm command
cmd
gogithub command
Package main provides the gogithub CLI tool.
Package main provides the gogithub CLI tool.
searchuserpr command
Package config provides configuration utilities for GitHub API clients.
Package config provides configuration utilities for GitHub API clients.
Package errors provides error types and translation utilities for GitHub API errors.
Package errors provides error types and translation utilities for GitHub API errors.
Package graphql provides GitHub GraphQL API utilities.
Package graphql provides GitHub GraphQL API utilities.
Package pathutil provides path validation and normalization utilities for GitHub repository paths.
Package pathutil provides path validation and normalization utilities for GitHub repository paths.
Package pr provides GitHub pull request operations.
Package pr provides GitHub pull request operations.
Package profile provides aggregated GitHub user profile statistics.
Package profile provides aggregated GitHub user profile statistics.
readme
Package readme generates GitHub profile README files from user profile data.
Package readme generates GitHub profile README files from user profile data.
svg
Package svg provides SVG stats card generation for GitHub profiles.
Package svg provides SVG stats card generation for GitHub profiles.
svg/chart
Package chart provides generic SVG chart generation.
Package chart provides generic SVG chart generation.
Package release provides GitHub release operations.
Package release provides GitHub release operations.
Package repo provides GitHub repository operations.
Package repo provides GitHub repository operations.
Package sarif provides helpers for uploading SARIF files to GitHub Code Scanning.
Package sarif provides helpers for uploading SARIF files to GitHub Code Scanning.
Package search provides GitHub search API functionality.
Package search provides GitHub search API functionality.
Package tag provides GitHub Git tag operations.
Package tag provides GitHub Git tag operations.

Jump to

Keyboard shortcuts

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