docs: update go sdk examples (#1393)

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
This commit is contained in:
Carlos Alexandro Becker
2026-04-14 20:50:39 -03:00
committed by GitHub
parent 66a60afe70
commit aaf86f6055
16 changed files with 122 additions and 156 deletions

View File

@@ -35,12 +35,12 @@ func main() {
session, err := client.CreateSession(ctx, &copilot.SessionConfig{
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
Model: "gpt-5",
Model: "gpt-5.4",
})
if err != nil {
log.Fatalf("Failed to create session: %v", err)
}
defer session.Destroy()
defer session.Disconnect()
result, err := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
if err != nil {
@@ -48,8 +48,10 @@ func main() {
return
}
if result != nil && result.Data.Content != nil {
fmt.Println(*result.Data.Content)
if result != nil {
if d, ok := result.Data.(*copilot.AssistantMessageData); ok {
fmt.Println(d.Content)
}
}
}
```
@@ -180,12 +182,12 @@ func doWork() error {
session, err := client.CreateSession(ctx, &copilot.SessionConfig{
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
Model: "gpt-5",
Model: "gpt-5.4",
})
if err != nil {
return fmt.Errorf("failed to create session: %w", err)
}
defer session.Destroy()
defer session.Disconnect()
// ... do work ...