Go SDK quick reference for agents
This page is checked against the Go CRUD and query examples at ekodb-client v0.37.0. The Go module is published separately as github.com/ekoDB/ekodb-client-go; v0.37.0 is the examples repository's baseline, not a Go module version. The pinned example go.mod requires Go client v0.31.1 and replaces it with the workspace checkout. Check the module revision used by the application before adopting a newer example.
Runnable Examples (Check Before Guessing)
Before writing SDK code, consult the matching runnable example below for exact imports, method signatures and error handling. These links follow the SDK's main branch; compare them with the version installed in your application. Follow the language directory's run instructions and use a disposable deployment when executing examples that write data.
| Task | Runnable example |
|---|---|
| CRUD | client_simple_crud.go |
| QueryBuilder | client_query_builder.go |
| Joins | client_joins.go |
| Schemas | client_schema.go |
| TTL | client_document_ttl.go |
| Transactions | client_transactions.go |
| Stored Functions | client_functions.go |
| Concurrency / Locks / RateLimits | client_concurrency_stages.go |
| Chat / RAG | client_chat_basic.go, rag_conversation_system.go |
| Search | client_search.go |
| WebSockets | client_websocket_subscribe.go |
| Admin / Permissions | client_admin.go |
Initialize and query
This function belongs in an application Go package. The application supplies runtime credentials:
import ekodb "github.com/ekoDB/ekodb-client-go"
func listActive(baseURL, apiKey string) ([]ekodb.Record, error) {
client, err := ekodb.NewClient(baseURL, apiKey)
if err != nil {
return nil, err
}
query := ekodb.NewQueryBuilder().Eq("active", true).Limit(25).Build()
return client.Find("agent_tasks", query)
}
NewClient returns (client, error) and handles token exchange. Do not drop its error or add an async/await layer to Go calls.
Method map
| Task | Call shape |
|---|---|
| Insert | client.Insert(collection, record) |
| Find | client.Find(collection, query) |
| Point read | client.FindByID(collection, id) |
| Merge update | client.Update(collection, id, fields) |
| Delete | client.Delete(collection, id) |
| Delete collection | client.DeleteCollection(collection) |
| Build filter / page | ekodb.NewQueryBuilder().Eq(field, value).Limit(n).Skip(offset).Build() |
Database operations return errors; propagate or classify each one. Query builders return the SDK query type. A manually built ekodb.Query uses pointer fields for optional limits (Limit: &limit), not a literal integer in that field.
Values and semantics
ekodb.Recordis a map. Use native booleans, slices and nested maps for data. Retain the returnedidfor point operations.- Responses may contain typed envelopes. Use
ekodb.ExtractRecord(record)or helpers such asGetStringValue,GetBoolValue,GetIntValue,GetObjectValueandGetArrayValue. Check each helper's return signature: for exampleGetIntValuereturns two values. - Insert may return only
id; fetch the record if other stored fields are needed. Do not assume every insert result echoes the input. - TTL, first-write types, filters, missing resources and Count results are server contracts; read canonical formats. Omitted record-update TTL preserves expiry, and
Countreplaces the working set with one result record. - Keep the HTTP status and server error when handling transactions. Never retry a commit solely on a 409 or infer that every Go method mirrors TypeScript's argument order.
The versioned Go examples include functions, TTL, schemas, joins and transactions. Use the matching example and the application's pinned Go module for those signatures. Use REST if a required method is absent from that installed module.