-
Notifications
You must be signed in to change notification settings - Fork 931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add:support file extension #1626
add:support file extension #1626
Conversation
Codecov Report
@@ Coverage Diff @@
## 3.0 #1626 +/- ##
==========================================
+ Coverage 40.94% 41.06% +0.11%
==========================================
Files 252 252
Lines 14443 14445 +2
==========================================
+ Hits 5914 5932 +18
+ Misses 7848 7830 -18
- Partials 681 683 +2
Continue to review full report at Codecov.
|
记得在samples 仓库里给出对应例子。 @zhaoyunxing92 |
@@ -155,11 +161,11 @@ func userHomeDir() string { | |||
|
|||
// checkGenre check Genre | |||
func checkGenre(genre string) error { | |||
genres := []string{"json", "toml", "yaml", "yml"} | |||
genres := []string{"json", "toml", "yaml", "yml", "properties"} | |||
sort.Strings(genres) | |||
idx := sort.SearchStrings(genres, genre) | |||
if genres[idx] != genre { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的判断是不是需要判断边界情况 idx == len(genres) || genres[idx] != genre
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1,idx 有没有可能是 -1 的情况?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
源码里面就是一个二分搜索,不会存在-1
的情况
func Search(n int, f func(int) bool) int {
// Define f(-1) == false and f(n) == true.
// Invariant: f(i-1) == false, f(j) == true.
i, j := 0, n
for i < j {
h := int(uint(i+j) >> 1) // avoid overflow when computing h
// i ≤ h < j
if !f(h) {
i = h + 1 // preserves f(i-1) == false
} else {
j = h // preserves f(j) == true
}
}
// i == j, f(i-1) == false, and f(j) (= f(i)) == true => answer is i.
return i
}
这个 pr 我看标识是 WIP,为啥都有两个 approve 了? |
我的锅,之前没注意到 |
What this PR does:
配置中心支持自定义文件类型解析器,目前支持
json
、yaml
、properties
、yml
、toml
五种文件类型配置Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: