github

package
v0.0.0-...-047dcd9 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRepoUrl

func BuildRepoUrl(user, repo string) string

func DownloadRepo

func DownloadRepo(user, repo, saveDir string, proxy string, timeout time.Duration) error

Download repository as zip file, and unzip it to specify save directory

func ParseUrl

func ParseUrl(githubUrl string) (user, repo, sub string, err error)

support github.com/***, www.github.com/***, gist.github.com/***

Types

type API

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

func (*API) GetAllReposInfo

func (c *API) GetAllReposInfo(user string) (*RepoInfoList, error)

func (*API) GetRateLimit

func (c *API) GetRateLimit() (RateLimit, error)

func (*API) GetRepoBasicInfoWithUrl

func (c *API) GetRepoBasicInfoWithUrl(repoUrl string) (*RepoInfo, error)

func (*API) GetRepoInfo

func (c *API) GetRepoInfo(user, repo string) (*RepoInfo, error)

type Client

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

func NewGithub

func NewGithub(token, proxy string) (*Client, error)

func (*Client) DownloadRepoFile

func (c *Client) DownloadRepoFile(filepath string) ([]byte, error)

example filepath: cartman/cartman-repo/reports/coin-tags.csv user: cartman repo: cartman-repo filepath: reports/tags.csv

filepath is different with public repo files' raw access url like: https://github.com/cartman/cartman-repo/raw/master/reports/tags.csv

func (*Client) GetAllReposInfo

func (c *Client) GetAllReposInfo(user string) (*RepoInfoList, error)

func (*Client) GetRateLimit

func (c *Client) GetRateLimit() (RateLimit, error)

type GitDrive

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

func NewGitDrive

func NewGitDrive(token, proxy string) (*GitDrive, error)

func (*GitDrive) CreatePartition

func (gd *GitDrive) CreatePartition(name string) error

func (*GitDrive) MyName

func (gd *GitDrive) MyName() (string, error)

func (*GitDrive) Partition

func (gd *GitDrive) Partition(name string) *GitPartition

func (*GitDrive) Partitions

func (gd *GitDrive) Partitions() ([]string, error)

type GitPartition

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

func (*GitPartition) LastUpdateTime

func (gp *GitPartition) LastUpdateTime() (time.Time, error)

func (*GitPartition) ReadAsZip

func (gp *GitPartition) ReadAsZip() ([]byte, error)

Download repository as zip file, and unzip it to specify save directory

func (*GitPartition) ReadFile

func (gp *GitPartition) ReadFile(file string) ([]byte, error)

func (*GitPartition) WriteFile

func (gp *GitPartition) WriteFile(file string, data []byte) error

type RateLimit

type RateLimit struct {
	CoreReqPerHour, SearchReqPerHour int
	CoreInterval, SearchInterval     time.Duration
}

type Release

type Release struct {
	Version       string
	DescTitle     string
	DescContent   string
	PublishedTime time.Time
	Assets        []ReleaseAsset
}

func GetLatestRelease

func GetLatestRelease(user, repo string) (*Release, error)

func (*Release) ParseCurrentPlatform

func (r *Release) ParseCurrentPlatform() (*ReleaseAsset, error)

根据文件名尝试分析当前平台对应的条目。 主要就是分析文件名中的"windows"/"darwin"/"linux","i386"/"arm64"/"amd64"等字样

type ReleaseAsset

type ReleaseAsset struct {
	Name        string
	ByteSize    int
	DownloadUrl string
}

type RepoInfo

type RepoInfo struct {
	Name               string
	CreateTime         time.Time
	RepoLastUpdateTime time.Time // Repository last updated time, include issue/wiki....
	CodeLastPushedTime time.Time // Source code last pushed time.
	StarsCount         int
	ForkCount          int
	Language           string
}

type RepoInfoList

type RepoInfoList struct {
	Items []RepoInfo
}

func (*RepoInfoList) MainRepo

func (rs *RepoInfoList) MainRepo() (*RepoInfo, error)

type Spider

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

func NewSpider

func NewSpider(proxy string) (*Spider, error)

func (*Spider) GetAllReposInfo

func (s *Spider) GetAllReposInfo(user string) (*RepoInfoList, error)

func (*Spider) GetRateLimit

func (s *Spider) GetRateLimit() (RateLimit, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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