yesno

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 yesno exposes the Yes/No API as a kit Domain.

A multi-domain host (ant) enables it with a single blank import:

import _ "github.com/tamnd/yesno-cli/yesno"

The same Domain also builds the standalone yesno binary.

Package yesno is the library behind the yesno command line: the HTTP client, request shaping, and the typed data models for the Yes/No API at yesno.wtf.

The API is completely open — no authentication or API key required. It paces requests and retries transient 429 and 5xx failures with exponential backoff.

Index

Constants

View Source
const BaseURL = "https://yesno.wtf"

BaseURL is the root every request is built from.

View Source
const Host = "yesno.wtf"

Host is the site this client talks to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct {
	Answer string `json:"answer" kit:"id"`
	Forced bool   `json:"forced"`
	Image  string `json:"image"`
}

Answer is one yes/no answer with an optional GIF image.

type Client

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

Client talks to yesno.wtf over HTTP.

func NewClient

func NewClient(cfg Config) *Client

NewClient returns a Client configured with cfg.

func (*Client) RandomAnswer

func (c *Client) RandomAnswer(ctx context.Context) (Answer, error)

RandomAnswer returns a random yes or no answer from yesno.wtf.

type Config

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

Config holds all tunable parameters for the Client.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a Config with sensible defaults.

type Domain

type Domain struct{}

Domain is the yesno driver.

func (Domain) Classify

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

Classify turns an input into the canonical (type, id).

func (Domain) Info

func (Domain) Info() kit.DomainInfo

Info describes the scheme, hosts, and binary identity.

func (Domain) Locate

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

Locate returns the live https URL for a (type, id).

func (Domain) Register

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

Register installs the client factory and all operations onto app.

Jump to

Keyboard shortcuts

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