No description
Implement an API-first Go rewrite with local engine adapters, upstream fallback, and Nix-based tooling so searches can run without matching the original UI while preserving response compatibility. Made-with: Cursor |
||
|---|---|---|
| cmd/searxng-go | ||
| internal | ||
| .gitignore | ||
| flake.lock | ||
| flake.nix | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
gosearch (SearXNG rewrite in Go)
This repository contains a standalone Go HTTP service that implements a SearXNG-compatible
API-first /search endpoint and proxies unported engines to an upstream SearXNG instance.
Endpoints
GET /healthz->OKGET|POST /search- Required form/body parameter:
q - Optional:
format(json|csv|rss; default:json)
- Required form/body parameter:
Supported format=...
json: SearXNG-style JSON response (query,number_of_results,results,answers,corrections,infoboxes,suggestions,unresponsive_engines)csv: CSV with headertitle,url,content,host,engine,score,typerss: RSS 2.0 feed based on theopensearch_response_rss.xmltemplate fields
Request parameters
The server accepts SearXNG form parameters (both GET query string and POST form-encoded):
q(required): search queryformat(optional):json/csv/rsspageno(optional, default1): positive integersafesearch(optional, default0): integer0..2time_range(optional):day|week|month|year(or omitted/None)timeout_limit(optional): float, seconds (or omitted/None)language(optional, defaultauto):autoor a BCP-47-ish language codeengines(optional): comma-separated engine names (e.g.wikipedia,arxiv)categories/category_<name>(optional): used for selecting the initial ported subsetengine_data-<engine>-<key>=<value>(optional): per-engine custom parameters
Environment variables
PORT(optional, default8080)UPSTREAM_SEARXNG_URL(optional for now, but required if you expect unported engines)- When set, unported engines are proxied to
${UPSTREAM_SEARXNG_URL}/searchwithformat=json.
- When set, unported engines are proxied to
LOCAL_PORTED_ENGINES(optional, defaultwikipedia,arxiv,crossref,braveapi,qwant)- Controls which engine names are executed locally (Go-native adapters).
HTTP_TIMEOUT(optional, default10s)- Timeout for both local engine API calls and upstream proxy calls.
- Brave Search API:
BRAVE_API_KEY(optional): enables thebraveapiengine when setBRAVE_ACCESS_TOKEN(optional): if set, requests must include a token (headerAuthorization: Bearer <token>,X-Search-Token,X-Brave-Access-Token, or form fieldtoken)
Ported vs proxied strategy
- The service plans which engines should run locally vs upstream using
LOCAL_PORTED_ENGINES. - It executes local ported engines using Go-native adapters:
wikipedia,arxiv,crossref
- Any remaining requested engines are proxied to upstream SearXNG (
format=json). - Responses are merged:
resultsare de-duplicated byengine|title|urlsuggestions/correctionsare treated as sets- other arrays are concatenated
Running with Nix
This repo uses flake.nix to provide the Go toolchain.
nix develop
go test ./...
go run ./cmd/searxng-go
Example:
export UPSTREAM_SEARXNG_URL="http://127.0.0.1:8888"
export PORT="8080"
nix develop -c go run ./cmd/searxng-go