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

# SubFlow

This page lists the Go SDK names for [SubFlows](https://docs.superdurable.io/zh-Hans/concepts/primitives/subflow.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                                                                                                     |
| ---------------------------------------------------- | ------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
| Start a child Flow and wait for it                   | **SubFlow** in **WaitFor**                                         | [SubFlows](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflows)                       |
| Set the child timeout, Attributes, and configuration | **SubFlowOptions**                                                 | [SubFlowOptions](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflow-options)          |
| Choose what happens to an existing child             | **ReusePolicy** of **SubFlowOptions**, with **SubFlowReusePolicy** | [SubFlowReusePolicy](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflow-reuse-policy) |
| Read the child result                                | **SubFlowResult** in **Execute**. It returns a **FlowResult**.     | [SubFlow results](https://docs.superdurable.io/zh-Hans/reference/go/waits.md#subflow-results)                    |
| Read the generated child Flow ID                     | **SubFlowID**                                                      | [SubFlowReusePolicy](https://docs.superdurable.io/zh-Hans/reference/server/runtime-data.md#subflow-reuse-policy) |
| Stop a child that lost an **AnyOf**                  | **Client.StopFlow** with the child Flow ID                         | [Stop a Flow](https://docs.superdurable.io/zh-Hans/reference/server/runtime-client.md#stop-a-flow)               |

<a id="step-type-rule"></a>

## Step types that start SubFlows

Changed in 1.45: a Step whose Step type contains "-" cannot start SubFlows.

The child Flow ID is "SubFlow:" followed by the parent Flow ID, the Step
execution ID, and the SubFlow index, joined with "-". The Step execution ID is
the Step type and a counter, also joined with "-". A dash in the Step type makes
the child Flow ID ambiguous, so two parents could share one child.

Default Step types are Go type names and never contain "-". Only a
**GetStepType** override can return one. When such a Step returns a **Wait**
with a **SubFlow** Condition, the Worker logs a warning and sends the
**WaitFor** result unchanged. Dex Server rejects it as an invalid Worker
response and fails the attempt without retry. Under the default policy, the
Flow fails. Steps with a dash that never start SubFlows are not affected.

To migrate, rename the Step type to a name without "-".

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

## Example

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