lostluck commented on a change in pull request #15057:
URL: https://github.com/apache/beam/pull/15057#discussion_r662652429



##########
File path: website/www/site/content/en/documentation/programming-guide.md
##########
@@ -716,11 +818,45 @@ static class ComputeWordLengthFn extends DoFn<String, 
Integer> {
 {{< code_sample "sdks/python/apache_beam/examples/snippets/snippets_test.py" 
model_pardo_pardo >}}
 {{< /highlight >}}
 
-{{< paragraph class="language-java" >}}
+{{< highlight go >}}
+{{< code_sample "sdks/go/examples/snippets/04transforms.go" model_pardo_pardo 
>}}
+{{< /highlight >}}
+
+{{< paragraph class="language-go" >}}
+Simple DoFns can also be written as functions.
+{{< /paragraph >}}
+
+{{< highlight go >}}
+func ComputeWordLengthFn(word string, emit func(int)) { ... }
+
+func init() {
+       beam.RegisterFunction(ComputeWordLengthFn)
+}
+{{< /highlight >}}
+
+<span class="language-go" >
+
+> **Note:** Wether using a structural `DoFn` type or a functional `DoFn`, they 
should be registered with
+> beam in an `init` block. Otherwise they may not execute on distributed 
runners.
+
+</span>
+
+<span class="language-java">
+
 > **Note:** If the elements in your input `PCollection` are key/value pairs, 
 > you
 > can access the key or value by using `element.getKey()` or
 > `element.getValue()`, respectively.
-{{< /paragraph >}}
+
+</span>
+
+<span class="language-go">
+
+> **Note:** If the elements in your input `PCollection` are key/value pairs, 
your
+> process element method must have two parameters, for each of the key and 
value,
+> respectively. Similarly, key/value pairs are also output as spearate

Review comment:
       Nice catch. Done.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to