linuxdo

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Overview

Package linuxdo is the library behind the linuxdo command: the HTTP client, request shaping, and the typed data models for linux.do.

The client fetches from the public Discourse JSON API at https://linux.do. No authentication is required. It sets a real User-Agent, paces requests, and retries transient 429/5xx errors with exponential backoff.

Index

Constants

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

DefaultUserAgent identifies the client to linux.do.

View Source
const Host = "linux.do"

Host is the hostname this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client talks to the linux.do Discourse JSON API.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client with the given config.

func (*Client) Topics

func (c *Client) Topics(ctx context.Context, path string) ([]TopicRecord, error)

Topics fetches topics from the given path (e.g. "/hot.json", "/latest.json", "/top/weekly.json") and returns the parsed list as TopicRecord values.

type Config

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

Config holds constructor parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults for linux.do.

type Domain added in v0.1.1

type Domain struct{}

Domain is the linux.do kit driver. It exposes hot, latest, and top topics from the Discourse-based linux.do forum. No API key is required.

func (Domain) Info added in v0.1.1

func (Domain) Info() kit.DomainInfo

Info returns the scheme, hostnames, and identity for the linuxdo domain.

func (Domain) Register added in v0.1.1

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

Register installs the client factory and the hot, latest, and top operations.

type Topic

type Topic struct {
	ID         int    `json:"id"`
	Title      string `json:"title"`
	Slug       string `json:"slug"`
	ReplyCount int    `json:"reply_count"`
	CreatedAt  string `json:"created_at"`
	LikeCount  int    `json:"like_count"`
	Views      int    `json:"views"`
}

Topic is a single Discourse topic record.

type TopicList

type TopicList struct {
	TopicList struct {
		Topics []Topic `json:"topics"`
	} `json:"topic_list"`
}

TopicList is the JSON envelope returned by the Discourse API.

type TopicRecord

type TopicRecord struct {
	Rank    int    `json:"rank"`
	Title   string `json:"title"`
	Replies int    `json:"replies"`
	Created string `json:"created"`
	Likes   int    `json:"likes"`
	Views   int    `json:"views"`
	URL     string `json:"url"`
}

TopicRecord is the output record emitted for every command.

Jump to

Keyboard shortcuts

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