Real-world examples demonstrating Dingo's features. Each example shows a practical use case with the Dingo source code and the generated Go output.
Each example folder contains:
*.dingo- Dingo source code*.go- Generated Go code (for comparison)README.md- Feature explanation, use cases, and generated code notes
| # | Feature | Scenario | Key Benefit |
|---|---|---|---|
| 01 | Error Propagation | HTTP handler | 67% less error handling boilerplate |
| 02 | Result Type | Database repository | Explicit success/failure modeling |
| 03 | Option Type | User settings | Zero nil pointer panics |
| 04 | Pattern Matching | Event handler | Exhaustive case handling |
| 05 | Sum Types | API responses | Type-safe variants |
| 06 | Lambdas | Data pipeline | Concise functional code |
| 07 | Tuples | Geometry | Group values without structs |
| 08 | Safe Navigation | Config access | Safe deep object traversal |
| 09 | Ternary | Permissions | Inline conditionals |
| 10 | Null Coalesce | Defaults | Chained fallback values |
func GetUser(id int) (*User, error) {
data, err := db.Query(id)
if err != nil {
return nil, err
}
user, err := parseUser(data)
if err != nil {
return nil, err
}
return user, nil
}func GetUser(id: int) (*User, error) {
data := db.Query(id)?
user := parseUser(data)?
return user, nil
}
# Transpile a single file
dingo build examples/01_error_propagation/http_handler.dingo
# Run the generated Go
go run examples/01_error_propagation/http_handler.goThese examples prioritize:
- Real scenarios - Code you'd actually write
- Honest comparison - Show both advantages and trade-offs
- Clarity - One feature per example
- Completeness - Both Dingo and generated Go code
The generated Go code shows exactly what Dingo produces - no magic, just cleaner syntax that transpiles to standard Go.