Allow the user to prefix our flags' names #54
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This problem has been reported quite a few times over the years; for
example, see it reported at golang-nuts mailing list 1, and cue lang
issue 2.
The problem is that, that glog package registers some flags in its
init() function. The list of registered flags also includes the
-v
flag, which is usually used by developers either to control verbosity of
their code-execution, or to show the software version. It's notable that
all the complaints are regarding the
-v
flag, and none about the otherflags, since those other flags are unlikely be used by any other
developer.
The proposed fix allows the user of the glog package to change/prefix
glog's flags' names, so that they will not conflict with any flags that
they want to use.
This approach to the problem has a few advantages, compared to other
options like, disabling all the flags in glog.
The default behaviour of the glog library is unchanged. So the
current users of the library will not be affected.
Any new users who wish to use the -v, or other glog-occupied flag,
can do so at build time.
The new users can still use the glog features/flags, albeit with a
prefix.
We are not enforcing some specific prefix, which may also conflict.
The --help flag, correctly reports the changed/prefixed flag names.
Please also see sample code 3 that demonstrates the problem, and how
the patch fixes the problem.