damondouglas commented on a change in pull request #15057: URL: https://github.com/apache/beam/pull/15057#discussion_r658381426
########## File path: sdks/go/examples/snippets/01_03intro.go ########## @@ -0,0 +1,93 @@ +// 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 snippets + +import ( + "flag" + + "github.com/apache/beam/sdks/go/pkg/beam" + "github.com/apache/beam/sdks/go/pkg/beam/io/textio" +) + +// PipelineConstruction contains snippets for the initial sections of +// the Beam Programming Guide, from initializing to submitting a +// pipeline. +func PipelineConstruction() { + // [START pipeline_options] + // If beamx or Go flags are used, flags must be parsed first, + // before beam.Init() is called. + flag.Parse() + // [END pipeline_options] + + // [START pipelines_constructing_creating] + // beam.Init() is an initialization hook that must be called near + // the beginging of main(). + beam.Init() + + // Create the Pipeline object and root scope. + pipeline, scope := beam.NewPipelineWithRoot() + // [END pipelines_constructing_creating] + + // [START pipelines_constructing_reading] + lines := textio.Read(scope, "gs://some/inputData.txt") + // [END pipelines_constructing_reading] + + _ = []interface{}{pipeline, scope, lines} +} + +// Create demonstrates using beam.CreateList. +func Create() { + // [START model_pcollection] + lines := []string{ + "To be, or not to be: that is the question: ", + "Whether 'tis nobler in the mind to suffer ", + "The slings and arrows of outrageous fortune, ", + "Or to take arms against a sea of troubles, ", + } + + // Create the Pipeline object and root scope. + p, s := beam.NewPipelineWithRoot() Review comment: Suggested change. In this example when it renders on the documentation, the reader is able to know that the `s` is the scope variable. However, in other examples it isn't as clear. ``` p, s := beam.NewPipelineWithRoot() linesPCol := beam.CreateList(s, lines) ``` to ``` pipeline, scope := beam.NewPipelineWithRoot() linesPCol := beam.CreateList(scope, lines) ``` -- 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]
