我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

眼镜蛇MarkPersistentFlagRequired不适用于Root

Using spf13/Cobra for cli flag parsing.

root command has a field marked required:

rootCmd.PersistentFlags().StringVarP(&configFilePath, "config", "c","", "REQUIRED: config file")
    rootCmd.MarkPersistentFlagRequired("config")    
    rootCmd.MarkFlagRequired("config")

However, cobra does not raise an error if it's the root command.

If I add a subcommand and add a required field, .MarkFlagRequired raises an error as expected if the argument is not provided on the command line.

近期文章

  • 网页模板Golang
  • 带有fmt.Scanln的VSCode golang调试问题
  • 是否可以在OS X上读写USB设备而不用C ++编写设备驱动程序?
  • 命名空间路由
  • 如何定义模拟方法被调用零次
  • 使具有多个依赖项的Golang业务方法可测试
  • 在Window 10中安装MinGW-W64编译器时,没有seh异常处理选项吗?
  • 如何使用go在mongodb查询中将$ or与$ lookup一起使用?
  • 如何使用go模块导入非执行目录(例如C src /)?
  • GOPATH使用Dep软件包的下划线复制路径
  • 在启用pkg / profile的情况下运行时如何获取样本?
  • 如何使用Colly在Golang中将字符串解析为DOM元素
  • 如何在Go中返回切片并从C调用?
  • Golang中的mqtt客户端偶尔断开连接
  • 软删除级联不起作用
  • 如何检索检查值
  • Go SDK中的DynamoDB查询`--limit 1`?
  • 如何将WinPcap链接到我的Go程序?
  • 如何从golang中的确切网址重定向?
  • Time to Graduate

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华