githubarchive

package
v0.0.0-...-24b9b75 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFiles

func DownloadFiles(pathname string) error

DownloadFiles copies githubarchive files locally

func FindDayPaths

func FindDayPaths(pathname string) ([]string, error)

FindDayPaths returns the locations of all day like things in a subdir hierarchy

func MaybeDownloadFile

func MaybeDownloadFile(basedir string, year int, month int, day int, hour int, dryrun bool) error

MaybeDownloadFile checks if the githubarchive file is missing, and if so downloads it

func ParseForkEvent

func ParseForkEvent(repo string, data []byte) (int64, string)

ParseForkEvent returns the forked repo name and forked repo id from a JSON githubarchive event

Types

type Event

type Event struct {
	Type         string
	RepoID       int64
	RepoName     string
	RepoLanguage string
	UserID       int64
	UserName     string
	ForkID       int64
	ForkName     string
	CreatedAt    string
}

Event holds parsed data about a single event from the Github Archive

func ParseEvent

func ParseEvent(data []byte) *Event

ParseEvent parses the JSON and returns a new Event struct. The JSON can be from multiple different formats produced by github over the years

type Scanner

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

Scanner scans over the contents of a githubarchive File

func NewScanner

func NewScanner(filename string) (*Scanner, error)

NewScanner open filename and creates a new scanner from its contents

func (*Scanner) Bytes

func (it *Scanner) Bytes() []byte

Bytes returns the current line as a byte array

func (*Scanner) Close

func (it *Scanner) Close()

Close the scanner

func (*Scanner) Err

func (it *Scanner) Err() error

Err returns the last error seen in scan

func (*Scanner) Event

func (it *Scanner) Event() *Event

Event returns the current Event, parsing the line from JSON

func (*Scanner) Scan

func (it *Scanner) Scan() bool

Scan for a valid entry. Returns if it found an entry (which can be accesssed through Event for the parsed version or Bytes the the raw version. On error this function returns false, and the error object is available on the Err member

Jump to

Keyboard shortcuts

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