Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the user to prefix our flags' names
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]. [1]: https://groups.google.com/g/golang-nuts/c/vj8ozVqemnQ [2]: cue-lang/cue#1199 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 other flags, 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. 1. The default behaviour of the glog library is unchanged. So the current users of the library will not be affected. 2. Any new users who wish to use the -v, or other glog-occupied flag, can do so at build time. 3. The new users can still use the glog features/flags, albeit with a prefix. 4. We are not enforcing some specific prefix, which may also conflict. 5. The --help flag, correctly reports the changed/prefixed flag names. ``` $ ./main --help Usage of ./main: ... other glog: prefixed flags ... -glog:v value log level for V logs -glog:vmodule value comma-separated list of pattern=N settings for file-filtered logging -v value Emit verbose execution progress ``` Please also see sample code [3] that demonstrates the problem, and how the patch fixes the problem. [3]: https://github.com/gurjeet/glog_fix_test
- Loading branch information