gist

package
v0.0.0-...-541f7c5 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Dir string
)
View Source
var Filename = "cache.json"

Functions

func ShortenID

func ShortenID(id string) string

Types

type Cache

type Cache struct {
	Ready   bool
	Path    string
	TTL     time.Duration
	Use     bool
	Updated time.Time
}

func NewCache

func NewCache() *Cache

func (*Cache) Available

func (c *Cache) Available() bool

func (*Cache) Cache

func (c *Cache) Cache(items Items) error

func (*Cache) Clear

func (c *Cache) Clear() error

func (*Cache) Expired

func (c *Cache) Expired() bool

func (*Cache) Load

func (c *Cache) Load() (items Items, err error)

type Client

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

func NewClient

func NewClient(token string) (c *Client, err error)

func (*Client) Create

func (c *Client) Create(files Files, desc string, private bool) (item Item, err error)

func (*Client) Delete

func (c *Client) Delete(id string) (err error)

func (*Client) Edit

func (c *Client) Edit(file File) (err error)

func (*Client) List

func (c *Client) List() (items Items, err error)

func (*Client) Sync

func (c *Client) Sync(file File) (err error)

type File

type File struct {
	ItemID   string `json:"item_id"`
	Filename string `json:"filename"`
	Content  string `json:"content"`
	// original field
	Path string `json:"path"`
}

func (*File) Exist

func (f *File) Exist() bool

func (*File) GetContent

func (f *File) GetContent() string

func (*File) Run

func (f *File) Run(args []string) error

func (*File) Runnable

func (f *File) Runnable() bool

type Files

type Files []File

type Item

type Item struct {
	ID          string `json:"id"`
	ShortID     string `json:"short_id"`
	Description string `json:"description"`
	Public      bool   `json:"public"`
	Files       []File `json:"files"`
	// original field
	URL  string `json:"url"`
	Path string `json:"path"`
}

func (*Item) Clone

func (i *Item) Clone() error

func (*Item) Exist

func (i *Item) Exist() bool

func (*Item) Exists

func (i *Item) Exists() bool

type Items

type Items []Item

func (*Items) CloneAll

func (i *Items) CloneAll()

func (*Items) Filter

func (i *Items) Filter(fn func(Item) bool) *Items

func (*Items) One

func (i *Items) One() Item

func (*Items) Render

func (items *Items) Render() []string

func (*Items) Unique

func (i *Items) Unique() Items

Jump to

Keyboard shortcuts

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