Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的代码
var require bool cmd.Flags().BoolVarP(&require, "require", "r", true, "default: true.")
如果默认值为“true”,天气我是否添加“-r”,“require”始终为“true”。但如果默认值为“false”,则效果很好。
请帮忙,谢谢!
如果布尔标志的默认值为 true,则不传递该标志而只传递-ror--require将导致true. 要将其设置为 false,请使用--require=false.
-r
--require
true
--require=false