Home > Article > Backend Development > In golang, can I use the flag package to define a flag that optionally accepts a string argument?
What I want to do is be able to run these three scenarios:
cmd --test --branchrelease
cmd --test all --branch release
cmd --branch release
You can specify --test yourself without parameters (such as Boolean values), and you can also specify parameters.
I don't think this is possible because the next flag (--branch) is used as an argument to --test when no arguments are given, but I thought I'd ask in case I'm missing something . p>
No, there is no such option.
The above is the detailed content of In golang, can I use the flag package to define a flag that optionally accepts a string argument?. For more information, please follow other related articles on the PHP Chinese website!