Contributing to 4got
Dev environment setup
- Clone the repo and
cdinto it. - Install Go 1.25+ (the
go.modrequires 1.25.0). - Build:
cd go-server && CGO_ENABLED=1 go build -o 4got . - Copy
data/config.default.kdltodata/config.kdland set yourowner-secret. - Run:
cd .. && go-server/4got
CGO is required for the SQLite driver.
Adding a new KDL engine
Generic engines are defined in data/engines.kdl and parsed by go-server/generic_engine.go. See engine-spec.md for the full KDL schema. The fastest workflow is the admin playground at /admin/engines/new (owner-only): fill in the form, test against a live query, then click “Save Engine” to append the KDL block to disk and register it without a restart.
Adding a new oracle
Oracles are instant-answer widgets shown above search results (calculator, unit converter, currency, etc.).
- Write your oracle function in
go-server/oracles_extra.go. Follow the existing pattern: the function takes a query string (and optionally*http.Request,http.ResponseWriter,Config) and returns*OracleAnsweror nil. - Register it in
go-server/oracles.goinsideCheckOracles(). Add a call to your function in the appropriate section (local oracles, API oracles, or knowledge oracles). Order matters: the first match in the local oracle section wins.
Running tests
cd go-server && CGO_ENABLED=1 go test ./...
Code style
- No comments unless the WHY is non-obvious. Do not explain what the code does if it is clear from reading it.
- AI-generated files get a header:
// AI-generated: <model> - Keep functions short. If a function needs a comment block explaining it, it should probably be smaller.
PR expectations
CGO_ENABLED=1 go build -o /dev/null .must pass.go vet ./...must be clean.- Do not introduce new linter warnings.