Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
二次元的罪恶王冠
beego
提交
fee3c2b8
B
beego
项目概览
二次元的罪恶王冠
/
beego
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
beego
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fee3c2b8
编写于
1月 15, 2014
作者:
A
astaxie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add Strings interface can return []string sep by ;
Example: peers = one;Two;Three
上级
b016102d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
37 addition
and
2 deletion
+37
-2
config/config.go
config/config.go
+3
-2
config/fake.go
config/fake.go
+4
-0
config/ini.go
config/ini.go
+5
-0
config/ini_test.go
config/ini_test.go
+8
-0
config/json.go
config/json.go
+5
-0
config/xml.go
config/xml.go
+6
-0
config/yaml.go
config/yaml.go
+6
-0
未找到文件。
config/config.go
浏览文件 @
fee3c2b8
...
...
@@ -6,8 +6,9 @@ import (
// ConfigContainer defines how to get and set value from configuration raw data.
type
ConfigContainer
interface
{
Set
(
key
,
val
string
)
error
// support section::key type in given key when using ini type.
String
(
key
string
)
string
// support section::key type in key string when using ini and json type; Int,Int64,Bool,Float,DIY are same.
Set
(
key
,
val
string
)
error
// support section::key type in given key when using ini type.
String
(
key
string
)
string
// support section::key type in key string when using ini and json type; Int,Int64,Bool,Float,DIY are same.
Strings
(
key
string
)
[]
string
//get string slice
Int
(
key
string
)
(
int
,
error
)
Int64
(
key
string
)
(
int64
,
error
)
Bool
(
key
string
)
(
bool
,
error
)
...
...
config/fake.go
浏览文件 @
fee3c2b8
...
...
@@ -25,6 +25,10 @@ func (c *fakeConfigContainer) String(key string) string {
return
c
.
getData
(
key
)
}
func
(
c
*
fakeConfigContainer
)
Strings
(
key
string
)
[]
string
{
return
strings
.
Split
(
c
.
getData
(
key
),
";"
)
}
func
(
c
*
fakeConfigContainer
)
Int
(
key
string
)
(
int
,
error
)
{
return
strconv
.
Atoi
(
c
.
getData
(
key
))
}
...
...
config/ini.go
浏览文件 @
fee3c2b8
...
...
@@ -146,6 +146,11 @@ func (c *IniConfigContainer) String(key string) string {
return
c
.
getdata
(
key
)
}
// Strings returns the []string value for a given key.
func
(
c
*
IniConfigContainer
)
Strings
(
key
string
)
[]
string
{
return
strings
.
Split
(
c
.
String
(
key
),
";"
)
}
// WriteValue writes a new value for key.
// if write to one section, the key need be "section::key".
// if the section is not existed, it panics.
...
...
config/ini_test.go
浏览文件 @
fee3c2b8
...
...
@@ -19,6 +19,7 @@ copyrequestbody = true
key1="asta"
key2 = "xie"
CaseInsensitive = true
peers = one;two;three
`
func
TestIni
(
t
*
testing
.
T
)
{
...
...
@@ -78,4 +79,11 @@ func TestIni(t *testing.T) {
if
v
,
err
:=
iniconf
.
Bool
(
"demo::caseinsensitive"
);
err
!=
nil
||
v
!=
true
{
t
.
Fatal
(
"get demo.caseinsensitive error"
)
}
if
data
:=
iniconf
.
Strings
(
"demo::peers"
);
len
(
data
)
!=
3
{
t
.
Fatal
(
"get strings error"
,
data
)
}
else
if
data
[
0
]
!=
"one"
{
t
.
Fatal
(
"get first params error not equat to one"
)
}
}
config/json.go
浏览文件 @
fee3c2b8
...
...
@@ -116,6 +116,11 @@ func (c *JsonConfigContainer) String(key string) string {
return
""
}
// Strings returns the []string value for a given key.
func
(
c
*
JsonConfigContainer
)
Strings
(
key
string
)
[]
string
{
return
strings
.
Split
(
c
.
String
(
key
),
";"
)
}
// WriteValue writes a new value for key.
func
(
c
*
JsonConfigContainer
)
Set
(
key
,
val
string
)
error
{
c
.
Lock
()
...
...
config/xml.go
浏览文件 @
fee3c2b8
...
...
@@ -5,6 +5,7 @@ import (
"io/ioutil"
"os"
"strconv"
"strings"
"sync"
"github.com/beego/x2j"
...
...
@@ -72,6 +73,11 @@ func (c *XMLConfigContainer) String(key string) string {
return
""
}
// Strings returns the []string value for a given key.
func
(
c
*
XMLConfigContainer
)
Strings
(
key
string
)
[]
string
{
return
strings
.
Split
(
c
.
String
(
key
),
";"
)
}
// WriteValue writes a new value for key.
func
(
c
*
XMLConfigContainer
)
Set
(
key
,
val
string
)
error
{
c
.
Lock
()
...
...
config/yaml.go
浏览文件 @
fee3c2b8
...
...
@@ -7,6 +7,7 @@ import (
"io/ioutil"
"log"
"os"
"strings"
"sync"
"github.com/beego/goyaml2"
...
...
@@ -117,6 +118,11 @@ func (c *YAMLConfigContainer) String(key string) string {
return
""
}
// Strings returns the []string value for a given key.
func
(
c
*
YAMLConfigContainer
)
Strings
(
key
string
)
[]
string
{
return
strings
.
Split
(
c
.
String
(
key
),
";"
)
}
// WriteValue writes a new value for key.
func
(
c
*
YAMLConfigContainer
)
Set
(
key
,
val
string
)
error
{
c
.
Lock
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录