Skip to content

Development

Igor Sazonov edited this page Sep 23, 2026 · 1 revision

This page is for contributors who modify defillama-go. The project uses only the Go standard library at runtime and targets Go 1.22 or newer. Tests use local HTTP servers, not live DefiLlama endpoints, so they do not require an API key or network access.1

Set up a local checkout

git clone https://github.com/tigusigalpa/defillama-go.git
cd defillama-go
go mod tidy

Run the checks

Run the following commands before submitting a pull request.

gofmt -l .            # Must print nothing.
go vet ./...
staticcheck ./...     # Install separately if not available.
golangci-lint run     # Run when installed.
go test ./...
go test -race ./...

The -race run is useful because the client is documented as safe to share across goroutines. The repository's HTTP tests use httptest.Server together with WithBaseURLsForTesting rather than calling DefiLlama directly.1

Understand the generated API surface

The pinned OpenAPI snapshot at spec/defillama-api.json is the source of truth for route coverage. Generated artifacts include routes.go, service files, option structs, and docs/api-index.md. Do not hand-build a base URL inside a service method. When adding or changing an endpoint, update the specification snapshot and regenerate the route registry, service files, options, and API index together.1

The current release covers 132 GET operations: 31 Free and 101 Pro. The route registry stores the route's tier, source origin, Pro override path where available, declared path/query parameters, enum values, and official documentation URL.2

Preserve API-key safety

Pro authentication embeds the key in a URL path segment as required by DefiLlama. Never add a path that puts the key into a log, error, header, body, or test fixture. Error handling intentionally redacts the key from URLs, response diagnostics, and nested transport errors. Tests should exercise this redaction behavior when transport code is modified.1

Documentation maintenance

Keep the README, docs/api-index.md, examples, and Wiki pages consistent with the public API. The Wiki bundle's API Reference is a copy of the source API index and should be refreshed whenever the generated endpoint index changes. Update examples when method signatures or option semantics change.

Reporting problems

Open ordinary bugs and feature requests as GitHub issues with a minimal reproduction. Remove API keys and other secrets from the report. For a security vulnerability, follow the repository's private disclosure policy rather than filing a public issue.1

References

Clone this wiki locally