jonathansudhakar1 opened a new pull request, #41041: URL: https://github.com/apache/beam/pull/41041
The Go commands on the [WordCount Example Walkthrough](https://beam.apache.org/get-started/wordcount-example/) no longer work with current Go. Each example says to run `go install github.com/apache/beam/sdks/v2/go/examples/<example>` with no version, and the Dataflow sections also run `go get -u golang.org/x/sys/unix`. Outside a module, Go 1.26 rejects both: ``` $ go install github.com/apache/beam/sdks/v2/go/examples/minimal_wordcount go: 'go install' requires a version when current directory is not in a module Try 'go install github.com/apache/beam/sdks/v2/go/examples/minimal_wordcount@latest' to install the latest version $ go get -u golang.org/x/sys/unix go: go.mod file not found in current directory or any parent directory. 'go get' is no longer supported outside a module. ``` The [Go quickstart](https://beam.apache.org/get-started/quickstart-go/) fixed the same problem in #27207 by switching to `go run …@latest`. This PR makes the same change on the walkthrough, for `minimal_wordcount`, `wordcount`, `debugging_wordcount` and `windowed_wordcount`: - `go install <pkg>` followed by running the binary becomes `go run <pkg>@latest <flags>`. - The Dataflow sections drop the `go get -u golang.org/x/sys/unix` step. - The Dataflow sections drop `--worker_harness_container_image`, as the quickstart did. Two of the three values point at `apache-docker-beam-snapshots-docker.bintray.io/beam/go:20180515` (Bintray shut down in 2021). The third is `apache/beam_go_sdk:latest`, which can differ from the SDK version that `@latest` builds. The flag is deprecated in favor of `--sdk_container_image`. Without it, the Dataflow runner uses `beam_go_sdk:<SDK version>` ([`getContainerImage`](https://github.com/apache/beam/blob/d8eb82acf2caac44e91e7d20c45070e12860b97e/sdks/go/pkg/beam/runners/dataflow/dataflow.go#L467-L492)). - The `windowed_wordcount` Dataflow command gets `--region your-gcp-region`, like the other two Dataflow commands on the page. Without a region (from the flag, `$CLOUDSDK_COMPUTE_REGION` or gcloud config), the Go Dataflow runner fails with "no Google Cloud region specified". Fixes #24785 ## Testing There's no local Hugo, so I ran the new commands directly. Each changed direct-runner command ran from an empty directory outside any Go module (Go 1.26.5, darwin/arm64, `GOFLAGS` unset). `@latest` resolved to `github.com/apache/beam/sdks/v2` **v2.77.0**. | Command (output names changed so the runs didn't overwrite each other) | Result | |---|---| | Old: `go install github.com/apache/beam/sdks/v2/go/examples/minimal_wordcount` | fails (error above) | | Old: `go get -u golang.org/x/sys/unix` | fails (error above) | | `go run …/minimal_wordcount@latest` | exit 0; read `gs://apache-beam-samples/shakespeare/kinglear.txt` and wrote `wordcounts.txt` (4,749 lines, e.g. `king: 65`) | | `go run …/wordcount@latest --input kinglear.txt --output counts` (local copy of King Lear) | exit 0; `counts` has the same 4,749 lines | | `go run …/debugging_wordcount@latest --input kinglear.txt --output debug_counts` | exit 0; logged `Matched: Flourish` and `Matched: stomach`, and the example's `passert` checks passed | | `go run …/windowed_wordcount@latest --input kinglear.txt --output windowed_counts` | exit 0; wrote the windowed counts | | `go run …/wordcount@latest --help` | lists every flag the Dataflow commands use: `-runner`, `-project`, `-region`, `-temp_location`, `-staging_location` | `git diff --check` is clean. `pre-commit run --files website/www/site/content/en/get-started/wordcount-example.md` had no applicable hooks. The Dataflow commands weren't run, because they need a GCP project. They now match the Go quickstart's Dataflow command, apart from the example name and indentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
