gitignore

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package gitignore provides an interface to gitignore.io to fetch gitignore templates. These templates are used to optionally populate the .gitignore file of a new project.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("gitignore template not found")

ErrNotFound is returned if a gitignore template could not be found.

Functions

This section is empty.

Types

type Client

type Client struct {
	*http.Client
	BaseURL string
}

Client can fetch gitignore templates.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient creates a new *Client which will use httpClient for making http requests. If httpClient is nil, http.DefaultClient will be used instead.

func (*Client) GetTemplate

func (c *Client) GetTemplate(ctx context.Context, query string) (*Template, error)

GetTemplate fetches the gitignore template for query. The query can be a comma-separated list of gitignore templates (e.g. "go,python") which are combined into a single gitignore template. Will return an error if the http connection fails or if the response status code is not 200. Will return ErrNotFound if any of the requested gitignore templates cannot be found.

func (*Client) ListTemplates

func (c *Client) ListTemplates(ctx context.Context) ([]string, error)

ListTemplates obtains a list of available gitignore templates. Will return an error if the http connection fails or the response status code is not 200.

type Template added in v0.1.1

type Template struct {
	Query   string
	Content []byte
}

Template holds the content of a gitignore template and the query that was used to obtain it.

Jump to

Keyboard shortcuts

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