cobra与glog冲突

cobra glog

cobra 和glog的flags会冲突

解决:


func main() {
	cmd.Execute()
}

func init(){
	pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
	flag.Set("logtostderr","true")
	flag.Parse()
}
func init() {
	if os.Args[1] == "-h" || os.Args[1] == "--help" {
		_ = rootCmd.Help()
		os.Exit(1)
	}
	//cobra.OnInitialize(initConfig)
	rootCmd.AddCommand(image.BatchCmd)
}