lostluck commented on a change in pull request #16719:
URL: https://github.com/apache/beam/pull/16719#discussion_r798933097
##########
File path: sdks/go/pkg/beam/core/runtime/options.go
##########
@@ -117,6 +118,23 @@ func (o *Options) Export() RawOptions {
return RawOptions{Options: copyMap(o.opt)}
}
+// LoadOptionsFromFlags adds any flags not defined in excludeFlags to the
options.
+// If the key is already defnined, it panics.
Review comment:
```suggestion
// If the key is already defined, it panics.
```
##########
File path: sdks/go/pkg/beam/runners/direct/direct.go
##########
@@ -65,6 +65,7 @@ func Execute(ctx context.Context, p *beam.Pipeline)
(beam.PipelineResult, error)
if err != nil {
return nil, errors.Wrap(err, "translation failed")
}
+ beam.PipelineOptions.LoadOptionsFromFlags(make(map[string]bool))
Review comment:
I just checked the go playground and at least at 1.17 it seems like
lookups in nil maps do not panic (they just return the default value for the
type). Prefer just passing in a nil instead, and if uncomfortable relying on
the default behavior, initializing it in the function instead.
Insertions to nil maps *do* panic though.
https://go.dev/play/p/H7QiTyKeAyU
--
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]