mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-14 02:10:00 +08:00
perf(config): optimize getfullname (#5328)
Co-authored-by: qiuwenhao <qiushaotest@qq.com>
This commit is contained in:
@@ -368,5 +368,5 @@ func getFullName(parent, child string) string {
|
|||||||
return child
|
return child
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.Join([]string{parent, child}, ".")
|
return parent + "." + child
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1377,3 +1377,23 @@ func (m mockConfig) Validate() error {
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetFullName(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
parent string
|
||||||
|
child string
|
||||||
|
want string
|
||||||
|
}{
|
||||||
|
{"", "child", "child"},
|
||||||
|
{"parent", "child", "parent.child"},
|
||||||
|
{"a.b", "c", "a.b.c"},
|
||||||
|
{"root", "nested.field", "root.nested.field"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.parent+"."+tt.child, func(t *testing.T) {
|
||||||
|
got := getFullName(tt.parent, tt.child)
|
||||||
|
assert.Equal(t, tt.want, got)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user