This is an automated email from the ASF dual-hosted git repository.
altay pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 938ee3e [BEAM-7354] Starcgen fix when no identifiers specified.
(#8611)
938ee3e is described below
commit 938ee3e805b40fdd5b1712a8bda9c9e0623fa470
Author: Daniel Oliveira <[email protected]>
AuthorDate: Tue May 21 18:18:54 2019 -0700
[BEAM-7354] Starcgen fix when no identifiers specified. (#8611)
If no identifiers are specified, the string.Split call as it is now
generates a slice of length 1 with one empty string, which isn't a valid
identifier and breaks the tool. This PR fixes it to the correct
behavior, to use an empty slice when there are no identifiers.
---
sdks/go/cmd/starcgen/starcgen.go | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sdks/go/cmd/starcgen/starcgen.go b/sdks/go/cmd/starcgen/starcgen.go
index e3b627b..601ec13 100644
--- a/sdks/go/cmd/starcgen/starcgen.go
+++ b/sdks/go/cmd/starcgen/starcgen.go
@@ -172,7 +172,11 @@ func main() {
if err != nil {
log.Fatalf("error opening %q: %v", *output, err)
}
- if err := Generate(f, *output, pkg, strings.Split(*ids, ","), fset,
fs); err != nil {
+ splitIds := make([]string, 0) // If no ids are specified, we should
pass an empty slice.
+ if len(*ids) > 0 {
+ splitIds = strings.Split(*ids, ",")
+ }
+ if err := Generate(f, *output, pkg, splitIds, fset, fs); err != nil {
log.Fatal(err)
}
}