Documentation
¶
Overview ¶
Package official reads what GitHub itself shows on a profile: earned badges, their tiers, unlock dates and milestone history, and the profile highlights.
None of this is in GitHub's API. It comes from the public profile page and from the /users/<user>/achievements/<slug>/detail fragment GitHub loads into the badge dialog. Both are HTML, so every parser here is covered by fixtures saved from real profiles and by a weekly canary against live pages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrUserNotFound = errors.New("user not found")
ErrUserNotFound means GitHub has no such user.
Functions ¶
func HasHighlight ¶
HasHighlight matches a highlight by its whole label, ignoring a leading count and a plural. A substring match would let "Pro" match "Developer Program Member".
func IsLogin ¶
IsLogin reports whether s can be a GitHub username. Every entry point checks it before a username reaches a URL or a search query.
func ParseEarned ¶
ParseEarned reads native achievement badge images and deduplicates their slugs.
func ParseHighlights ¶
ParseHighlights returns the labels in the profile's Highlights list.
Types ¶
type Client ¶
type Client struct {
HTTP *http.Client
Base string // https://github.com
}
Client fetches official pages from github.com.
type Detail ¶
type Detail struct {
Slug string `json:"slug"`
Name string `json:"name"`
Tier int `json:"tier"`
Unlocked string `json:"unlocked,omitempty"` // first unlock date, YYYY-MM-DD
Milestones []Milestone `json:"milestones,omitempty"`
}
Detail is GitHub's own record of one earned badge.
func ParseDetail ¶
ParseDetail reads one badge's detail fragment.
type Milestone ¶
type Milestone struct {
N int `json:"n,omitempty"` // the ordinal GitHub counted to (2nd → 2), 0 if none
PR string `json:"pr,omitempty"` // "owner/repo#123", empty when private ("inaccessible")
Repo string `json:"repo,omitempty"` // "owner/repo" for repository milestones (Starstruck)
Label string `json:"label"`
}
Milestone is one row of a badge's history, e.g. "2nd pull request merged".