Open
Conversation
Author
|
@shafreeck 看一下这种实现方式是否可行。 |
shafreeck
requested changes
Jul 15, 2019
configo.go
Outdated
| } | ||
|
|
||
| // apply flag param | ||
| ApplyFlags(v) |
Collaborator
There was a problem hiding this comment.
感觉放到这里,或默认启用flag不太合适,比如我只想解析toml,不想使用flag呢?
是不是考虑将Unmarshal, ApplyFlags, ApplyEnvs 当做独立的函数,然后通过更上层的函数合并起来?
flags.go
Outdated
| ./cmd -array="[\"a1\", \"a2\"]" | ||
| */ | ||
|
|
||
| var flagMap map[string]struct{} = nil |
Collaborator
There was a problem hiding this comment.
flagMap 能否省掉? 比如直接查询FlagSet?
Collaborator
|
最好翻译为英文, 可以寻求下@xuehuaying 的协助 |
|
这个pr需要我帮助吗? |
Author
先等确认版本的,确认之后再翻译,谢谢! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
通过在
flag.Parse()之前调用configo.AddFlags()方法,即可实现将配置文件中的参数添加到flag中,从而可以通过命令行设置配置文件参数。