github

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: BSD-2-Clause Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseWebHook

func ParseWebHook(messageType string, payload []byte) (any, error)

ParseWebHook parses the raw webhook payload into a typed go-github event value. This wraps github.ParseWebHook so consumers do not need to import go-github directly.

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to the given value, equivalent to go-github's github.Ptr.

func WebHookType

func WebHookType(r *http.Request) string

WebHookType returns the X-GitHub-Event header value from the request. This wraps github.WebHookType so consumers do not need to import go-github directly.

Types

type API

type API interface {
	FindIssueCommentWithMarker(ctx context.Context, owner, repo string, issueNumber int, marker string) (*IssueComment, error)
	CreateIssueComment(ctx context.Context, owner, repo string, issueNumber int, body string) (*IssueComment, error)
	UpdateIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) (*IssueComment, error)
	GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)
}

API is the handler-facing interface satisfied by *Client. It exists for dependency injection in handler tests; the shared library provides one implementation. Methods take only the operation's intrinsic arguments; auth is applied by the authTransport on the underlying http client.

type Client

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

Client is the GitHub API client used by handlers. It is built on top of go-github, authenticated with a static token via authTransport.

func NewClient

func NewClient(httpClient *http.Client, baseURL string, options ...Option) (*Client, error)

NewClient returns a Client authenticated with the supplied token, issuing requests against baseURL using httpClient's transport.

A nil httpClient falls back to http.DefaultClient. The caller's *http.Client is not mutated; we shallow-copy before installing the auth transport wrapper.

baseURL "" or "https://api.github.com" targets public GitHub. Any other value retargets the underlying go-github client at a GHES instance via WithEnterpriseURLs.

func (*Client) CreateIssueComment

func (c *Client) CreateIssueComment(ctx context.Context, owner, repo string, issueNumber int, body string) (*IssueComment, error)

CreateIssueComment creates a comment on the specified issue or pull request.

func (*Client) FindIssueCommentWithMarker

func (c *Client) FindIssueCommentWithMarker(ctx context.Context, owner, repo string, issueNumber int, marker string) (*IssueComment, error)

FindIssueCommentWithMarker lists issue comments and returns the first one whose body contains the marker string. Returns nil, nil if no matching comment is found.

func (*Client) GetPullRequest

func (c *Client) GetPullRequest(ctx context.Context, owner, repo string, number int) (*PullRequest, error)

GetPullRequest retrieves a pull request by number.

func (*Client) RoundTrip added in v1.0.7

func (c *Client) RoundTrip(req *http.Request) (*http.Response, error)

func (*Client) UpdateIssueComment

func (c *Client) UpdateIssueComment(ctx context.Context, owner, repo string, commentID int64, body string) (*IssueComment, error)

UpdateIssueComment updates an existing issue comment by ID.

type IssueComment

type IssueComment struct {
	ID   int64
	Body string
}

IssueComment represents a GitHub issue or PR comment.

type Option added in v1.0.7

type Option func(c *Client) error

func WithToken added in v1.0.7

func WithToken(token string) Option

type PullRequest

type PullRequest struct {
	ID    int64
	State string
	User  PullRequestUser
}

PullRequest represents a GitHub pull request as returned by GetPullRequest.

type PullRequestUser

type PullRequestUser struct {
	Login string
}

PullRequestUser carries the login of a pull request author.

Jump to

Keyboard shortcuts

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