add go limitions

Signed-off-by: mikeee <hey@mike.ee>
This commit is contained in:
mikeee 2024-02-29 00:10:05 +00:00
parent 020324e843
commit 464d3c7088
No known key found for this signature in database
GPG Key ID: ACED13988580D50E
1 changed files with 56 additions and 7 deletions

View File

@ -172,7 +172,7 @@ APIs that generate random numbers, random UUIDs, or the current date are _non-de
For example, instead of this:
{{< tabs ".NET" Java JavaScript >}}
{{< tabs ".NET" Java JavaScript Go>}}
{{% codetab %}}
@ -207,11 +207,20 @@ const randomString = getRandomString();
{{% /codetab %}}
{{% codetab %}}
```go
// DON'T DO THIS!
const currentTime = time.Now()
```
{{% /codetab %}}
{{< /tabs >}}
Do this:
{{< tabs ".NET" Java JavaScript >}}
{{< tabs ".NET" Java JavaScript Go >}}
{{% codetab %}}
@ -245,6 +254,14 @@ const randomString = yield context.callActivity(getRandomString);
{{% /codetab %}}
{{% codetab %}}
```go
const currentTime = ctx.CurrentUTCDateTime()
```
{{% /codetab %}}
{{< /tabs >}}
@ -255,7 +272,7 @@ Instead, workflows should interact with external state _indirectly_ using workfl
For example, instead of this:
{{< tabs ".NET" Java JavaScript >}}
{{< tabs ".NET" Java JavaScript Go >}}
{{% codetab %}}
@ -298,11 +315,20 @@ fetch('https://postman-echo.com/get')
{{% /codetab %}}
{{% codetab %}}
```go
// DON'T DO THIS!
```
{{% /codetab %}}
{{< /tabs >}}
Do this:
{{< tabs ".NET" Java JavaScript >}}
{{< tabs ".NET" Java JavaScript Go >}}
{{% codetab %}}
@ -346,7 +372,7 @@ Failure to follow this rule could result in undefined behavior. Any background p
For example, instead of this:
{{< tabs ".NET" Java JavaScript >}}
{{< tabs ".NET" Java JavaScript Go >}}
{{% codetab %}}
@ -375,11 +401,24 @@ Don't declare JavaScript workflow as `async`. The Node.js runtime doesn't guaran
{{% /codetab %}}
{{% codetab %}}
```go
// DON'T DO THIS!
go func() {
err := ctx.CallActivity(DoSomething).Await(nil)
}()
err := ctx.CreateTimer(time.Second).Await(nil)
```
{{% /codetab %}}
{{< /tabs >}}
Do this:
{{< tabs ".NET" Java JavaScript >}}
{{< tabs ".NET" Java JavaScript Go >}}
{{% codetab %}}
@ -407,6 +446,16 @@ Since the Node.js runtime doesn't guarantee that asynchronous functions are dete
{{% /codetab %}}
{{% codetab %}}
```go
// Do this!
task := ctx.CallActivity(DoSomething)
task.Await(nil)
```
{{% /codetab %}}
{{< /tabs >}}
@ -440,4 +489,4 @@ To work around these constraints:
- [Python](https://github.com/dapr/python-sdk/tree/master/examples/demo_workflow)
- [JavaScript example](https://github.com/dapr/js-sdk/tree/main/examples/workflow)
- [.NET](https://github.com/dapr/dotnet-sdk/tree/master/examples/Workflow)
- [Java](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/workflows)
- [Java](https://github.com/dapr/java-sdk/tree/master/examples/src/main/java/io/dapr/examples/workflows)