Go Deployment
Deploy high-performance Genkit applications written in Go. Build standalone HTTP servers with minimal resource usage and maximum throughput.Overview
Genkit Go provides:- Native performance - Compiled binaries, no runtime overhead
- Small footprint - Minimal memory and CPU usage
- Standard library - Built on
net/http, works with any Go HTTP framework - Single binary - Self-contained executable
Installation
Basic Server
1. Create main.go
main.go
2. Initialize Go Module
3. Run Locally
Streaming Flows
Define flows that stream responses:Advanced Features
Using Model References
Configure provider-specific options:Structured Output
Streaming Structured Data
Tools
HTTP Frameworks
Standard Library (net/http)
Genkit works seamlessly with the standard library:Gin
Echo
Chi
Frameworks with Error Handling
Usegenkit.HandlerFunc for frameworks that support error-returning handlers:
Build and Deployment
Build Binary
Dockerfile
Dockerfile
Deploy to Cloud Run
Deploy to Fly.io
fly.toml
Deploy to AWS
Production Best Practices
1. Graceful Shutdown
2. Timeouts
3. Structured Logging
4. Health Checks
5. Middleware
Complete Examples
See full Go examples in the repository:Performance Tips
- Use connection pooling - HTTP clients reuse connections by default
- Enable HTTP/2 - Automatically enabled in Go 1.6+
- Set appropriate buffer sizes - For large responses
- Use context for cancellation - Pass request context to Genkit calls
- Profile your app - Use
pprofto identify bottlenecks
Troubleshooting
Missing API Key
Problem:googlegenai: API key not found
Solution: Set environment variable:
Port Already in Use
Problem:bind: address already in use
Solution: Change port or kill existing process:
Large Binary Size
Problem: Binary is too large. Solution: Strip debug symbols:Next Steps
Go README
Full Go SDK documentation
Cloud Run
Deploy to Google Cloud Run