Documentation
¶
Index ¶
- Constants
- func AddHeaders(req *http.Request)
- func CreateDatabase(filename string) error
- func FileExists(filename string) bool
- func GetConfigFileName() string
- func GetGistPages() chan string
- func GetGists(jsonstr string) chan Gist
- func LoadDatabase(db *sql.DB, gist Gist) error
- func MakeInitialURL() string
- func MakeNextURL(resp *http.Response) string
- type Configuration
- type Gist
- type GistFile
- type Link
Constants ¶
const ( PACKAGE_NAME = "gists" CONFIG_FILE_NAME = "config.yaml" )
const ( URL_PREFIX = "https://api.github.com/users" URL_SUFFIX = "gists?per_page=10" LINK_HEADER_NAME = "Link" REL_NEXT_NAME = "next" )
Variables ¶
This section is empty.
Functions ¶
func AddHeaders ¶
AddHeaders adds the required authorization headers to the HTTP request.
func CreateDatabase ¶
CreateDatabase reads gists from a channel and writes them to an SQLite3 database.
func FileExists ¶
FileExists returns true if the specified file exists
func GetConfigFileName ¶
func GetConfigFileName() string
GetConfigFileName returns the name of the configuration file for this user.
func GetGistPages ¶
func GetGistPages() chan string
GetGistPages downloads pages of gists from GitHub, sending them back as strings of JSON arrays.
func GetGists ¶
GetGists accepts a string containing a JSON array of gists and passes the individual gists back through a channel.
func LoadDatabase ¶
LoadDatabase writes a gist to the database
func MakeInitialURL ¶
func MakeInitialURL() string
MakeInitialURL creates the URL for the first page of the gists
func MakeNextURL ¶
MakeNextURL finds the URL for the next page of the gists, or blank, if there are no more pages.
Types ¶
type Configuration ¶
Configuration contains the Github username and token
var Config *Configuration
func LoadConfig ¶
func LoadConfig(filename string) (*Configuration, error)
LoadConfig reads the specified file and produces a configuration structure from it by parsing it as YAML.
type Gist ¶
type Gist struct { ID string `json:"id,omitempty"` URL string `json:"url,omitempty"` Description string `json:"description,omitempty"` CreatedAt string `json:"created_at"` Files map[string]GistFile `json:"files,omitempty"` }
Gist represents a single Github gist
type GistFile ¶
type GistFile struct { Filename string `json:"filename,omitempty"` Type string `json:"type,omitempty"` Language string `json:"language,omitempty"` RawURL string `json:"raw_url,omitempty"` Size int `json:"size,omitempty"` }
GistFile represents a single file in a gist, not including the content, which is pointed to by RawURL.
func NewGistFile ¶
NewGistFile creates a new GistFile structure from its JSON representation.
func (GistFile) GetContents ¶
GetContents retrieves the actual file contents from GitHub.