henryken commented on a change in pull request #11340: [BEAM-9678] Create Go SDK introduction kata URL: https://github.com/apache/beam/pull/11340#discussion_r407074183
########## File path: learning/katas/go/Introduction/Hello Beam/Hello Beam/task.go ########## @@ -0,0 +1,36 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package task + +import ( + "context" + "github.com/apache/beam/sdks/go/pkg/beam" + "github.com/apache/beam/sdks/go/pkg/beam/x/beamx" +) + +func Task() (err error) { Review comment: I don't prefer having to run the test using output file. I propose the following solution here and in the task.go (and the equivalent test code in the task_test.go). We can have the LogElements function as part of a utility module. The reason we need the LogElements is so that the learner is able to run the program and observe the output. Also I think it's better to use `func main()`. ```go func main() { ctx := context.Background() p, s := beam.NewPipelineWithRoot() helloBeam := HelloBeam(s) LogElements(s, ctx, helloBeam) if err := beamx.Run(ctx, p); err != nil { log.Exitf(ctx, "Failed to execute job: %v", err) } } func HelloBeam(s beam.Scope) beam.PCollection { return beam.Create(s, "Hello Beam") } func LogElements(s beam.Scope, ctx context.Context, helloBeam beam.PCollection) beam.PCollection { return beam.ParDo(s, func(w string) string { log.Infof(ctx, "%s", w) return w }, helloBeam) } ``` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
