Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
ba89253e
Unverified
Commit
ba89253e
authored
Apr 20, 2018
by
umasuo
Committed by
GitHub
Apr 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update yaml.go
add support for multilevel yaml config
parent
f1668881
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
yaml.go
config/yaml/yaml.go
+17
-3
No files found.
config/yaml/yaml.go
View file @
ba89253e
...
@@ -285,9 +285,23 @@ func (c *ConfigContainer) getData(key string) (interface{}, error) {
...
@@ -285,9 +285,23 @@ func (c *ConfigContainer) getData(key string) (interface{}, error) {
if
len
(
key
)
==
0
{
if
len
(
key
)
==
0
{
return
nil
,
errors
.
New
(
"key is empty"
)
return
nil
,
errors
.
New
(
"key is empty"
)
}
}
keys
:=
strings
.
Split
(
key
,
"."
)
if
v
,
ok
:=
c
.
data
[
key
];
ok
{
tmpData
:=
c
.
data
return
v
,
nil
for
_
,
k
:=
range
keys
{
if
v
,
ok
:=
tmpData
[
k
];
ok
{
switch
v
.
(
type
)
{
case
map
[
string
]
interface
{}
:
{
tmpData
=
v
.
(
map
[
string
]
interface
{})
}
default
:
{
return
v
,
nil
}
}
}
}
}
return
nil
,
fmt
.
Errorf
(
"not exist key %q"
,
key
)
return
nil
,
fmt
.
Errorf
(
"not exist key %q"
,
key
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment