Replies: 2 comments 3 replies
-
|
Another approach is to replace |
Beta Was this translation helpful? Give feedback.
-
|
This seems rather unfortunate to put it mildly, and something we should attempt to fix via a PR to the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
When upgrading a program importing a package from cue v0.3.0-beta* to v0.4.0 I noted that CUE's new dependency github.com/protocolbuffers/txtpbfmt adds another dependency, github.com/golang/glog (leveled execution logs for Go).
go mod whylists, for instance:Glog, as a package, in its init function defines some command line flags using Go's standard flag package:
As a result, any program importing, for example,
cuelang.org/go/cue/loadwill automatically inherit these flags. In my program, which makes use of the standard flag package, I had been defining an ownflag.Uint("v", 0, "verbosity level").With cue v0.4.0 I'm getting a
panic: ... flag redefined: verror now.Since the
cueprogram itself is using cobra+pflag, this effect is not visible when using cue itself, since flags defined using Go's standard flag package are ignored then.An old thread at golang-nuts, glog and testing flag "pollution" mentions a workaround: defining one's own flag.FlagSet instead of using the default
flag.CommandLine. But this also means, that all flags defined by a program's internal packages using e.g.flag.Boolmust be adapted to the new FlagSet.An alternative to this workaround would be to make
textprotodepend on a modifiedtxtpbfmtthat does not depend on glog. I think for my use-case I will apply the method described in that golang-nuts thread.Beta Was this translation helpful? Give feedback.
All reactions