Skip to content

Commit db546c6

Browse files
stephentoubCopilot
andcommitted
Fix Go doc example: type-assert SessionEventData to AssistantMessageData
The Go SDK uses per-event-type data structs, so response.Data is a SessionEventData interface. Access Content by type-asserting to *copilot.AssistantMessageData. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 04c2bd8 commit db546c6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

docs/setup/local-cli.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ func main() {
9999

100100
session, _ := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"})
101101
response, _ := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
102-
fmt.Println(*response.Data.Content)
102+
if d, ok := response.Data.(*copilot.AssistantMessageData); ok {
103+
fmt.Println(d.Content)
104+
}
103105
}
104106
```
105107
<!-- /docs-validate: hidden -->
@@ -115,7 +117,9 @@ defer client.Stop()
115117

116118
session, _ := client.CreateSession(ctx, &copilot.SessionConfig{Model: "gpt-4.1"})
117119
response, _ := session.SendAndWait(ctx, copilot.MessageOptions{Prompt: "Hello!"})
118-
fmt.Println(*response.Data.Content)
120+
if d, ok := response.Data.(*copilot.AssistantMessageData); ok {
121+
fmt.Println(d.Content)
122+
}
119123
```
120124

121125
</details>

0 commit comments

Comments
 (0)