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

@@ -139,7 +139,7 @@ func main() {
cwd, _ := os.Getwd()
session, err := client.CreateSession(ctx, &copilot.SessionConfig{
OnPermissionRequest: copilot.PermissionHandler.ApproveAll,
Model: "gpt-5",
Model: "gpt-5.4",
SystemMessage: &copilot.SystemMessageConfig{
Content: fmt.Sprintf(`
<context>
@@ -159,19 +159,15 @@ The current working directory is: %s
if err != nil {
log.Fatal(err)
}
defer session.Destroy()
defer session.Disconnect()
// Set up event handling
session.On(func(event copilot.SessionEvent) {
switch event.Type {
case "assistant.message":
if event.Data.Content != nil {
fmt.Printf("\n🤖 %s\n\n", *event.Data.Content)
}
case "tool.execution_start":
if event.Data.ToolName != nil {
fmt.Printf(" ⚙️ %s\n", *event.Data.ToolName)
}
switch d := event.Data.(type) {
case *copilot.AssistantMessageData:
fmt.Printf("\n🤖 %s\n\n", d.Content)
case *copilot.ToolExecutionStartData:
fmt.Printf(" ⚙️ %s\n", d.ToolName)
}
})