You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by lo...@apache.org on 2022/06/22 23:20:36 UTC

[beam-starter-go] 14/17: remove redundant function

This is an automated email from the ASF dual-hosted git repository.

lostluck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/beam-starter-go.git

commit 74206bc8e76ab0bd433ba77766e33909976c2cf0
Author: David Cavazos <dc...@google.com>
AuthorDate: Fri Jun 17 14:08:58 2022 -0700

    remove redundant function
---
 main.go | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/main.go b/main.go
index 9c513c5..1c00014 100644
--- a/main.go
+++ b/main.go
@@ -17,15 +17,10 @@ var (
 
 func init() {
 	// DoFns should be registered with Beam to be available in distributed runners.
-	beam.RegisterFunction(toTitleCase)
+	beam.RegisterFunction(strings.Title)
 	beam.RegisterFunction(logAndEmit)
 }
 
-// A simple function would take the element as an argument and return a single value.
-func toTitleCase(element string) string {
-	return strings.Title(element)
-}
-
 // You can also access the Context and "emit" zero or more values like FlatMap.
 func logAndEmit(ctx context.Context, element string, emit func(string)) {
 	beamLog.Infoln(ctx, element)
@@ -34,7 +29,7 @@ func logAndEmit(ctx context.Context, element string, emit func(string)) {
 
 func MyPipeline(scope beam.Scope, input_text string) beam.PCollection {
 	elements := beam.Create(scope, "hello", "world!", input_text)
-	elements = beam.ParDo(scope, toTitleCase, elements)
+	elements = beam.ParDo(scope, strings.Title, elements)
 	return beam.ParDo(scope, logAndEmit, elements)
 }