gogi

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: BSD-3-Clause Imports: 6 Imported by: 1

README

gogi - Go client for gitignore.io

Build Status Go Reference Go Report Card

Why gogi?

Make gitignore client more portable, without relying on the shell, curl, wget or any other http client.

Installation

go get -u github.com/cuonglm/gogi

Usage

As library

import (
	"fmt"
	"log"

	"github.com/cuonglm/gogi"
)

func main() {
	gogiClient, _ := gogi.NewHTTPClient()
	data, err := gogiClient.List()
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(data)
}

As binary:

$ go get github.com/cuonglm/gogi/cmd/gogi
$ gogi
Usage of gogi:
  -create string
    	Create .gitignore content for given types
  -list
    	List all defined types
  -search string
    	Show all types match string

Using docker

Using gnouc/gogi image
$ docker pull gnouc/gogi
$ docker run --rm gnouc/gogi -search python
ipythonnotebook
python
Building your own image

Building builder image

docker build -t gogi-builder -f Dockerfile.build .

Building binary image

docker run --rm gogi-builder | docker build -t gogi -f Dockerfile.run -

Environment variables

GOGI_API_URL to change your gitignore server, default to https://www.gitignore.io

Author

Cuong Manh Le cuong.manhle.vn@gmail.com

License

See LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithAPIUrl added in v0.0.3

func WithAPIUrl(u string) func(*Client) error

WithAPIUrl sets the API url option for gogi client

func WithHTTPClient added in v0.0.3

func WithHTTPClient(client *http.Client) func(*Client) error

WithHTTPClient sets the client option for gogi client

Types

type Client

type Client struct {
	UserAgent string
	APIURL    *url.URL
	// contains filtered or unexported fields
}

Client for querying API

func NewHTTPClient

func NewHTTPClient(options ...func(*Client) error) (*Client, error)

NewHTTPClient create new gogi client

func (*Client) Create

func (c *Client) Create(typeName string) (string, error)

Create creates .gitignore file content for given input type.

func (*Client) Do

func (c *Client) Do(req *http.Request) (resp *http.Response, err error)

Do make an http request

func (*Client) List

func (c *Client) List() (string, error)

List lists all defined gitignore types with lines format

func (*Client) ListJson added in v1.0.1

func (c *Client) ListJson() (map[string]*ListJsonItem, error)

ListJson lists all defined gitignore types with json format.

func (*Client) NewRequest

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

NewRequest create new http request

type ListJsonItem added in v1.0.1

type ListJsonItem struct {
	Contents string `json:"contents"`
	FileName string `json:"fileName"`
	Key      string `json:"key"`
	Name     string `json:"name"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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