Help us shape the future of Go! Take the 2026 Go Developer Survey

webresearch

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OutcomeOK                 = "ok"
	OutcomeRequestFailed      = "request_failed"
	OutcomeResponseTooLarge   = "response_too_large"
	OutcomeUnsupportedContent = "unsupported_content"
	OutcomeExtractionFailed   = "extraction_failed"
)

Variables

This section is empty.

Functions

func AdmissibleHTTPS

func AdmissibleHTTPS(raw string) (string, bool)

AdmissibleHTTPS reports whether raw names an HTTPS target FetchText would admit, returning its canonical credential-redacted form. A caller that surfaces a URL before any fetch runs it through here so it cannot offer a target the fetch path would later refuse. The result is never length-bounded: a cut through a percent escape names a different target or no valid URL at all, so a caller with a field limit must drop an over-long candidate rather than truncate it.

func GuardedDialContext

func GuardedDialContext(ctx context.Context, network, address string) (net.Conn, error)

Types

type Authorizer

type Authorizer func(ctx context.Context, target Target) error

Authorizer decides one Target before its request is built. Any non-nil error, whether a denial or an undecidable request, means nothing is sent.

type Candidate

type Candidate struct {
	Title         string
	URL           string
	Snippet       string
	PublishedDate string
}

type FetchResult

type FetchResult struct {
	FinalURL string `json:"final_url,omitempty"`
	Content  string `json:"content,omitempty"`
	Outcome  string `json:"outcome"`
}

func FetchText

func FetchText(ctx context.Context, client *http.Client, rawURL string, authorize Authorizer, outputCap int) FetchResult

type SearchBackend

type SearchBackend interface {
	Search(ctx context.Context, query string) ([]Candidate, error)
}

SearchBackend runs one query against a search provider. The returned candidates keep the provider's relevance order, and no provider or transport type crosses this boundary.

type Target

type Target struct {
	Host              string
	Scheme            string
	Port              string
	URL               string
	FreshConfirmation bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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