gpt4 book ai didi

go - 双破折号停止标志解析

转载 作者:IT王子 更新时间:2023-10-29 02:35:25 25 4
gpt4 key购买 nike

我见过几种工具可以利用双破折号来停止将命令行参数解释为标志。

有没有办法对标准库中的标志包做同样的事情?

原因是我的应用程序正在包装另一个应用程序,并且两个应用程序都有一个 -v 标志来打开详细输出。

我可以简单地更改我的应用程序的标志定义,但我很想知道这是否适用于标准库,但类似的事情似乎没有记录或根本不存在。

最佳答案

Double dash to stop flag parsing

I'm curious to know if this is doable with the standard library but something like this does not seem to be documented.


Package flag

import "flag"

Flag parsing stops just before the first non-flag argument ("-" is a non-flag argument) or after the terminator "--".


阅读文档。

关于go - 双破折号停止标志解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55506492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com