mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-22 11:25:13 +00:00
All 5 Go recipes and their markdown docs used incorrect API patterns that don't match the real github.com/github/copilot-sdk/go v0.1.23: - copilot.NewClient() -> copilot.NewClient(nil) (*ClientOptions param) - client.Start() -> client.Start(ctx) (context.Context required) - copilot.SessionConfig -> &copilot.SessionConfig (pointer required) - session.On(func(event copilot.Event)) -> session.On(func(event copilot.SessionEvent)) - Type assertions -> event.Type string check + *event.Data.Content deref - session.WaitForIdle() -> session.SendAndWait(ctx, ...) (WaitForIdle doesn't exist) - copilot.SystemMessage -> copilot.SystemMessageConfig All 5 recipes verified to compile against SDK v0.1.23.
Runnable Recipe Examples
This folder contains standalone, executable Go examples for each cookbook recipe. Each file is a complete program that can be run directly with go run.
Prerequisites
- Go 1.21 or later
- GitHub Copilot SDK for Go
go get github.com/github/copilot-sdk/go
Running Examples
Each .go file is a complete, runnable program. Simply use:
go run <filename>.go
Available Recipes
| Recipe | Command | Description |
|---|---|---|
| Error Handling | go run error-handling.go |
Demonstrates error handling patterns |
| Multiple Sessions | go run multiple-sessions.go |
Manages multiple independent conversations |
| Managing Local Files | go run managing-local-files.go |
Organizes files using AI grouping |
| PR Visualization | go run pr-visualization.go |
Generates PR age charts |
| Persisting Sessions | go run persisting-sessions.go |
Save and resume sessions across restarts |
Examples with Arguments
PR Visualization with specific repo:
go run pr-visualization.go -repo github/copilot-sdk
Managing Local Files (edit the file to change target folder):
# Edit the targetFolder variable in managing-local-files.go first
go run managing-local-files.go
Go Best Practices
These examples follow Go conventions:
- Proper error handling with explicit checks
- Use of
deferfor cleanup - Idiomatic naming (camelCase for local variables)
- Standard library usage where appropriate
- Clean separation of concerns