Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
张磊
/
FileStorageBeego
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
2ba12ad1
authored
2015-04-05 23:21:13 +0800
by
astaxie
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
config read and set support Runmode
1 parent
8cc57e2f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
config.go
config.go
View file @
2ba12ad
...
...
@@ -98,6 +98,10 @@ func newAppConfig(AppConfigProvider, AppConfigPath string) (*beegoAppConfig, err
}
func
(
b
*
beegoAppConfig
)
Set
(
key
,
val
string
)
error
{
err
:=
b
.
innerConfig
.
Set
(
RunMode
+
"::"
+
key
,
val
)
if
err
==
nil
{
return
err
}
return
b
.
innerConfig
.
Set
(
key
,
val
)
}
...
...
@@ -150,26 +154,50 @@ func (b *beegoAppConfig) Float(key string) (float64, error) {
}
func
(
b
*
beegoAppConfig
)
DefaultString
(
key
string
,
defaultval
string
)
string
{
v
:=
b
.
String
(
key
)
if
v
!=
""
{
return
v
}
return
b
.
innerConfig
.
DefaultString
(
key
,
defaultval
)
}
func
(
b
*
beegoAppConfig
)
DefaultStrings
(
key
string
,
defaultval
[]
string
)
[]
string
{
v
:=
b
.
Strings
(
key
)
if
len
(
v
)
!=
0
{
return
v
}
return
b
.
innerConfig
.
DefaultStrings
(
key
,
defaultval
)
}
func
(
b
*
beegoAppConfig
)
DefaultInt
(
key
string
,
defaultval
int
)
int
{
v
,
err
:=
b
.
Int
(
key
)
if
err
==
nil
{
return
v
}
return
b
.
innerConfig
.
DefaultInt
(
key
,
defaultval
)
}
func
(
b
*
beegoAppConfig
)
DefaultInt64
(
key
string
,
defaultval
int64
)
int64
{
v
,
err
:=
b
.
Int64
(
key
)
if
err
==
nil
{
return
v
}
return
b
.
innerConfig
.
DefaultInt64
(
key
,
defaultval
)
}
func
(
b
*
beegoAppConfig
)
DefaultBool
(
key
string
,
defaultval
bool
)
bool
{
v
,
err
:=
b
.
Bool
(
key
)
if
err
==
nil
{
return
v
}
return
b
.
innerConfig
.
DefaultBool
(
key
,
defaultval
)
}
func
(
b
*
beegoAppConfig
)
DefaultFloat
(
key
string
,
defaultval
float64
)
float64
{
v
,
err
:=
b
.
Float
(
key
)
if
err
==
nil
{
return
v
}
return
b
.
innerConfig
.
DefaultFloat
(
key
,
defaultval
)
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment