github

package
v0.0.0-...-2847b59 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: MIT Imports: 11 Imported by: 2

Documentation

Overview

github is a Go library for accessing the Github API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present.

Types

type Client

type Client struct {

	// Services used for handling the Github API.
	Repositories *RepositoriesService
	// contains filtered or unexported fields
}

A Client manages communication with the Github API.

func NewClient

func NewClient(ctx context.Context, token string) *Client

NewClient returns a new GitLab API client. You must provide a valid token.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) GetBaseURL

func (c *Client) GetBaseURL() *url.URL

GetBaseURL returns a copy of the baseURL.

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request using a relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client.

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(urlStr string) error

SetBaseURL sets the base URL for API requests to a custom endpoint. urlStr should always be specified with a trailing slash.

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
	Message  string         `json:"message"` // error message
}

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type RepositoriesService

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

Github API docs: https://docs.gitlab.com/ce/api/repositories.html

func (*RepositoriesService) List

List the repositories for a user.

GitHub API docs: https://developer.github.com/v3/repos/#list-user-repositories

type Repository

type Repository struct {
	ID          int64  `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	GitURL      string `json:"git_url"`
}

Repository represents a GitHub repository.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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