---
title: "Stream"
description: "This page lists the Go SDK names for Streams."
canonical_url: "https://docs.superdurable.io/zh-Hans/reference/go/stream/"
source: "docs/reference/go/stream.mdx"
locale: "zh-Hans"
---

# Stream

This page lists the Go SDK names for [Streams](https://docs.superdurable.io/zh-Hans/concepts/primitives/stream.md).
The doc comment of each API gives its parameters, defaults, and errors. Read
them in the [Go SDK API reference](https://docs.superdurable.io/zh-Hans/reference/go.md#api-reference).

<a id="api-names"></a>

## API names

| Task                                     | Go API                                                                        | Dex behavior                                                                                                     |
| ---------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| Define a Stream and its byte capacity    | **DefineStream**, with its **streamCapacityBytes** argument                   | [Capacity and trimming](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#stream-capacity)   |
| Declare it in the Flow                   | **Streams** of **PersistenceSchema**, returned from **GetPersistenceSchema**  | [Flow definition](https://docs.superdurable.io/zh-Hans/reference/go/flow.md#flow-definition)                     |
| Write a message from a Step              | **Stream.Write**                                                              | [Write semantics](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#stream-write-semantics)  |
| Write text chunks in batches from a Step | **NewBufferedTextStream**, which returns a **BufferedTextStream**             | [Buffer text chunks](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#stream-buffered-text) |
| Write a message from a Client            | **Client.WriteStream**                                                        | [Write semantics](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#stream-write-semantics)  |
| Read the next message                    | **Client.ReadStream**, with the **ResumeToken** of the last **StreamMessage** | [Resumable reads](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#stream-resumable-reads)  |
| List retained messages, newest first     | **Client.ListStreamMessages**, into a **StreamMessagesPage**                  | [List messages](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#stream-listing)            |

**Stream.Write** works in **WaitFor**, **Execute**, and the Flow timeout
handler. An RPC handler cannot write a Stream. **Stream.Write** sends the
message right away. Its error covers only local validation, encoding, and
transport.

<a id="example"></a>

## Example

Example: [examples/go/primitives/stream/workflow.go](https://github.com/superdurable/dex/tree/main/examples/go/primitives/stream/workflow.go)
