ossucs

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ossucs is the library behind the ossucs command line: the HTTP client, request shaping, and the typed data models for the OSSU Computer Science curriculum.

The Client here is the spine every command shares. It sets a real User-Agent, paces requests so a busy session stays polite, and retries the transient failures (429 and 5xx) that any public site throws under load.

Index

Constants

View Source
const DefaultUserAgent = "ossucs/dev (+https://github.com/tamnd/ossucs-cli)"

DefaultUserAgent identifies the client to the remote host.

View Source
const Host = "github.com/ossu/computer-science"

Host is the site the URI driver in domain.go claims.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP *http.Client
	// contains filtered or unexported fields
}

Client talks to raw.githubusercontent.com over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured by cfg.

func (*Client) Courses

func (c *Client) Courses(ctx context.Context) ([]*Course, error)

Courses fetches the OSSU Computer Science README and returns all courses with their section, title, URL, and rank.

type Config

type Config struct {
	BaseURL   string
	Rate      time.Duration
	Timeout   time.Duration
	Retries   int
	UserAgent string
}

Config holds all tunables for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config pointed at raw.githubusercontent.com with conservative pacing and retry settings.

type Course

type Course struct {
	Rank    int    `json:"rank"    csv:"rank"    tsv:"rank"`
	Section string `json:"section" csv:"section" tsv:"section"`
	Title   string `json:"title"   csv:"title"   tsv:"title"`
	URL     string `json:"url"     csv:"url"     tsv:"url"`
}

Course is one course in the OSSU Computer Science curriculum.

type Domain

type Domain struct{}

Domain is the ossucs driver. It carries no state; the per-run client is built by the factory Register hands kit.

func (Domain) Classify

func (Domain) Classify(input string) (uriType, id string, err error)

Classify turns a reference into (type, id). Courses are addressed by rank.

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, the hostnames a pasted link is matched against, and the identity reused for the binary's help and version.

func (Domain) Locate

func (Domain) Locate(uriType, id string) (string, error)

Locate is the inverse: the live https URL for a (type, id).

func (Domain) Register

func (Domain) Register(app *kit.App)

Register installs the client factory and every operation onto app.

Jump to

Keyboard shortcuts

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