A Go library and CLI tool for generating and ingesting mock/synthetic data using Go templates.
- Template Engine - Generate dynamic data using Go's
text/template. See Template Engine section.- Use built-in functions like random generation, probability, counters, and more.
- Runner Engine - Ingest generated data using implemented Runners. See Runner Engine section.
- Concurrent Execution - You can execute the runner
ntimes using multiple goroutines.
- Concurrent Execution - You can execute the runner
- Persistence - You can save Templates and Runners to reuse later.
- Mock server - Create mock servers using the Template Engine and the OpenAPI Specification.
go install github.com/aaron70/decoy/cmd/decoy@latestOr build from source:
git clone https://github.com/aaron70/decoy.git
cd decoy
go build -o decoy ./cmd/decoy/main.godecoy template store greet -t 'Hello, {{ coalesce .Name "World" }}!'decoy template parse greet --data '{ "Name": "Doe" }'decoy runner store echo -c 'echo User said: "{{ .template }}"' decoy runner run cmd echo greet -v Name=Doedecoy server rest start -f ./spec.yamldecoy template --help
decoy template parse --help
decoy runner --help
decoy runner run --help
decoy server --help
decoy server start --helppackage main
import (
"fmt"
"github.com/aaron70/decoy/pkg/decoy"
)
func main() {
d, _ := decoy.NewDecoyWithSeed(42)
result, _ := d.ParseTemplateString(
`{"id": {{nextIncrementalInt "counter" 1 1}}, "name": "{{randomName}} {{randomLastName}}"}`,
)
fmt.Println(result)
}All random generation functions (RandomInt, RandomFloat, RandomBoolean, RandomChoice, RandomText, RandomName, etc.) are available as methods on Decoy or via the decoy.RandomChoice generic function.
- CLI Reference — Full command usage, runner engine configuration, advanced examples
- Template Functions — Complete function signatures, parameters, and examples
- Server API Reference — Decoy server API and mock server.
Templates, runners, and server specs are stored as JSON files under ~/.config/decoy/ (or $XDG_CONFIG_HOME/decoy).