model

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 1 Imported by: 0 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

Overview

Package model holds the types the other packages share: gists, their files and comments, as gist uses them rather than as GitHub sends them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	// Description is nil to leave it.
	Description *string
	// Files are by the name the file has now. A name the gist does not have
	// adds a file, which takes Content.
	Files map[string]FileChange
}

Change is what to change in a gist.

func (Change) Empty

func (c Change) Empty() bool

Empty says the change changes nothing.

type Comment

type Comment struct {
	ID      int64     `json:"id"`
	Author  string    `json:"author"`
	Body    string    `json:"body"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

Comment is a comment on a gist.

type File

type File struct {
	Name     string `json:"name"`
	Type     string `json:"type"`
	Language string `json:"language,omitempty"`
	Size     int64  `json:"size"`
	// RawURL points at this file at the revision read.
	RawURL string `json:"raw_url"`
	// Content is for showing: only a single gist has it, and it is not the
	// file as written, since the API client rewrites control characters and
	// Truncated cuts it. Editing and printing use the raw content instead.
	Content   string `json:"content,omitempty"`
	Truncated bool   `json:"truncated,omitempty"`
	// Binary says a file read whole is not text. Content then means nothing.
	Binary bool `json:"binary,omitempty"`
}

File is a file of a gist.

type FileChange

type FileChange struct {
	// Remove removes the file. The other fields are then not used.
	Remove bool
	// Content is the new content, nil to leave it.
	Content *string
	// Name is the new name, nil to leave it.
	Name *string
}

FileChange is what to do to a file of a gist.

type Gist

type Gist struct {
	ID          string    `json:"id"`
	Description string    `json:"description"`
	Owner       string    `json:"owner"`
	Public      bool      `json:"public"`
	URL         string    `json:"url"`
	Comments    int       `json:"comments"`
	Created     time.Time `json:"created"`
	Updated     time.Time `json:"updated"`
	// Files are sorted by name, the order GitHub shows them in.
	Files []File `json:"files"`
	// History is the revisions, newest first. Only a single gist has it, not
	// a list. Changing just the description makes no revision.
	History []string `json:"history,omitempty"`
}

Gist is a gist. A list from GitHub leaves out what the fields say they need Get for.

func (Gist) Revision

func (g Gist) Revision() string

Revision is the gist's latest revision, or "" when History was not read.

type ListPage

type ListPage struct {
	Number int
	// Last is the number of the last page, when the page says, which only the
	// first does and not when it is NotModified.
	Last int
	// ETag asks for the page again only if it changed.
	ETag string
	// NotModified says the page is as it was for ETag, and Gists is empty.
	NotModified bool
	Gists       []Gist
}

ListPage is a page of the list of the user's gists as read.

type NewGist

type NewGist struct {
	Description string
	Public      bool
	// Files are the names and contents.
	Files map[string]string
}

NewGist is a gist to create.

type Release

type Release struct {
	// Version is the tag without its leading v, such as "2.0.0".
	Version   string
	Published time.Time
	// Body is the release notes, Markdown as GitHub generated them.
	Body string
}

Release is a release of gist on GitHub.

Jump to

Keyboard shortcuts

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