This directory contains example programs demonstrating various features of the Trusera Go SDK.
Each example is a standalone Go program. To run them:
cd examples/basic
go run main.goReplace "your-api-key" in the code with your actual Trusera API key.
File: basic/main.go
Demonstrates:
- Creating a Trusera client
- Tracking different event types (tool calls, LLM invocations, data access, decisions)
- Using the builder pattern for events
- Manual flushing
File: http-interceptor/main.go
Demonstrates:
- Wrapping an HTTP client with Trusera interception
- Warn mode enforcement
- Exclude patterns to skip certain URLs
- Block patterns for policy evaluation
- POST requests with bodies
File: block-mode/main.go
Demonstrates:
- Block mode enforcement (rejecting blocked requests)
- Agent registration and HTTP interception in one call
- Handling blocked request errors
- Multiple block patterns
All examples use placeholder API keys. Before running:
- Sign up at https://trusera.io
- Get your API key from the dashboard
- Replace
"your-api-key"in the example code
- Examples use public APIs that may have rate limits
- Block mode examples use fake domains for demonstration
- All events are sent to the Trusera API for analysis and compliance reporting