golang中的pflag示例
现在晚上在家啃kubeadm的源码, 在啃源码前,pflag,viper,cobra这三件套好像是必须的, 那就先弄懂一下这三个套件的套路吧。 第一个,pflag. https://www.cnblogs.com/sparkdev/p/10833186.html https://github.com/spf13/pflag pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags. pflag is compatible with the GNU extensions to the POSIX recommendations for command-line options . For a more precise description, see the "Command-line flag syntax" section below. pflag 包与 flag 包的工作原理甚至是代码实现都是类似的,下面是 pflag 相对 flag 的一些优势: 支持更加精细的参数类型:例如,flag 只支持 uint 和 uint64,而 pflag 额外支持 uint8、uint16、int32 等类型。 支持更多参数类型:ip、ip mask、ip net