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
1b04571c
Commit
1b04571c
authored
Mar 14, 2016
by
ysqi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test the env use GOPATH not GOROOT
parent
9c7d95b0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
29 deletions
+29
-29
config.go
config/config.go
+1
-1
ini_test.go
config/ini_test.go
+7
-7
json_test.go
config/json_test.go
+9
-9
xml_test.go
config/xml/xml_test.go
+5
-5
yaml_test.go
config/yaml/yaml_test.go
+7
-7
No files found.
config/config.go
View file @
1b04571c
...
@@ -132,7 +132,7 @@ func ChooseRealValueForMap(m map[string]interface{}) map[string]interface{} {
...
@@ -132,7 +132,7 @@ func ChooseRealValueForMap(m map[string]interface{}) map[string]interface{} {
//
//
// It accept value formats "$$env" , "$$env||" , "$$env||defaultValue" , "defaultvalue".
// It accept value formats "$$env" , "$$env||" , "$$env||defaultValue" , "defaultvalue".
// Examples:
// Examples:
// v1 := config.ChooseRealValue("$$GO
ROOT") // return the GOROOT
environment variable.
// v1 := config.ChooseRealValue("$$GO
PATH") // return the GOPATH
environment variable.
// v2 := config.ChooseRealValue("$$GOAsta||/usr/local/go/") // return the default value "/usr/local/go/".
// v2 := config.ChooseRealValue("$$GOAsta||/usr/local/go/") // return the default value "/usr/local/go/".
// v3 := config.ChooseRealValue("Astaxie") // return the value "Astaxie".
// v3 := config.ChooseRealValue("Astaxie") // return the value "Astaxie".
func
ChooseRealValue
(
value
string
)
(
realValue
string
)
{
func
ChooseRealValue
(
value
string
)
(
realValue
string
)
{
...
...
config/ini_test.go
View file @
1b04571c
...
@@ -42,9 +42,9 @@ needlogin = ON
...
@@ -42,9 +42,9 @@ needlogin = ON
enableSession = Y
enableSession = Y
enableCookie = N
enableCookie = N
flag = 1
flag = 1
path1 = $$GO
ROOT
path1 = $$GO
PATH
path2 = $$GO
ROOT
||/home/go
path2 = $$GO
PATH
||/home/go
path3 = $$GO
ROOT
$$GOPATH2||/home/go
path3 = $$GO
PATH
$$GOPATH2||/home/go
token1 = $$TOKEN
token1 = $$TOKEN
token2 = $$TOKEN||
token2 = $$TOKEN||
token3 = $$TOKEN||astaxie
token3 = $$TOKEN||astaxie
...
@@ -55,7 +55,7 @@ key1="asta"
...
@@ -55,7 +55,7 @@ key1="asta"
key2 = "xie"
key2 = "xie"
CaseInsensitive = true
CaseInsensitive = true
peers = one;two;three
peers = one;two;three
password = $$GO
ROOT
password = $$GO
PATH
`
`
keyValue
=
map
[
string
]
interface
{}{
keyValue
=
map
[
string
]
interface
{}{
...
@@ -73,8 +73,8 @@ password = $$GOROOT
...
@@ -73,8 +73,8 @@ password = $$GOROOT
"enableSession"
:
true
,
"enableSession"
:
true
,
"enableCookie"
:
false
,
"enableCookie"
:
false
,
"flag"
:
true
,
"flag"
:
true
,
"path1"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path1"
:
os
.
Getenv
(
"GO
PATH
"
),
"path2"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path2"
:
os
.
Getenv
(
"GO
PATH
"
),
"path3"
:
"/home/go"
,
"path3"
:
"/home/go"
,
"token1"
:
""
,
"token1"
:
""
,
"token2"
:
""
,
"token2"
:
""
,
...
@@ -85,7 +85,7 @@ password = $$GOROOT
...
@@ -85,7 +85,7 @@ password = $$GOROOT
"demo::key2"
:
"xie"
,
"demo::key2"
:
"xie"
,
"demo::CaseInsensitive"
:
true
,
"demo::CaseInsensitive"
:
true
,
"demo::peers"
:
[]
string
{
"one"
,
"two"
,
"three"
},
"demo::peers"
:
[]
string
{
"one"
,
"two"
,
"three"
},
"demo::password"
:
os
.
Getenv
(
"GO
ROOT
"
),
"demo::password"
:
os
.
Getenv
(
"GO
PATH
"
),
"null"
:
""
,
"null"
:
""
,
"demo2::key1"
:
""
,
"demo2::key1"
:
""
,
"error"
:
""
,
"error"
:
""
,
...
...
config/json_test.go
View file @
1b04571c
...
@@ -86,9 +86,9 @@ func TestJson(t *testing.T) {
...
@@ -86,9 +86,9 @@ func TestJson(t *testing.T) {
"enableSession": "Y",
"enableSession": "Y",
"enableCookie": "N",
"enableCookie": "N",
"flag": 1,
"flag": 1,
"path1": "$$GO
ROOT
",
"path1": "$$GO
PATH
",
"path2": "$$GO
ROOT
||/home/go",
"path2": "$$GO
PATH
||/home/go",
"path3": "$$GO
ROOT
$$GOPATH2||/home/go",
"path3": "$$GO
PATH
$$GOPATH2||/home/go",
"token1": "$$TOKEN",
"token1": "$$TOKEN",
"token2": "$$TOKEN||",
"token2": "$$TOKEN||",
"token3": "$$TOKEN||astaxie",
"token3": "$$TOKEN||astaxie",
...
@@ -99,12 +99,12 @@ func TestJson(t *testing.T) {
...
@@ -99,12 +99,12 @@ func TestJson(t *testing.T) {
"port": "port",
"port": "port",
"database": "database",
"database": "database",
"username": "username",
"username": "username",
"password": "$$GO
ROOT
",
"password": "$$GO
PATH
",
"conns":{
"conns":{
"maxconnection":12,
"maxconnection":12,
"autoconnect":true,
"autoconnect":true,
"connectioninfo":"info",
"connectioninfo":"info",
"root": "$$GO
ROOT
"
"root": "$$GO
PATH
"
}
}
}
}
}`
}`
...
@@ -124,8 +124,8 @@ func TestJson(t *testing.T) {
...
@@ -124,8 +124,8 @@ func TestJson(t *testing.T) {
"enableSession"
:
true
,
"enableSession"
:
true
,
"enableCookie"
:
false
,
"enableCookie"
:
false
,
"flag"
:
true
,
"flag"
:
true
,
"path1"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path1"
:
os
.
Getenv
(
"GO
PATH
"
),
"path2"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path2"
:
os
.
Getenv
(
"GO
PATH
"
),
"path3"
:
"/home/go"
,
"path3"
:
"/home/go"
,
"token1"
:
""
,
"token1"
:
""
,
"token2"
:
""
,
"token2"
:
""
,
...
@@ -135,11 +135,11 @@ func TestJson(t *testing.T) {
...
@@ -135,11 +135,11 @@ func TestJson(t *testing.T) {
"database::host"
:
"host"
,
"database::host"
:
"host"
,
"database::port"
:
"port"
,
"database::port"
:
"port"
,
"database::database"
:
"database"
,
"database::database"
:
"database"
,
"database::password"
:
os
.
Getenv
(
"GO
ROOT
"
),
"database::password"
:
os
.
Getenv
(
"GO
PATH
"
),
"database::conns::maxconnection"
:
12
,
"database::conns::maxconnection"
:
12
,
"database::conns::autoconnect"
:
true
,
"database::conns::autoconnect"
:
true
,
"database::conns::connectioninfo"
:
"info"
,
"database::conns::connectioninfo"
:
"info"
,
"database::conns::root"
:
os
.
Getenv
(
"GO
ROOT
"
),
"database::conns::root"
:
os
.
Getenv
(
"GO
PATH
"
),
"unknown"
:
""
,
"unknown"
:
""
,
}
}
)
)
...
...
config/xml/xml_test.go
View file @
1b04571c
...
@@ -35,9 +35,9 @@ func TestXML(t *testing.T) {
...
@@ -35,9 +35,9 @@ func TestXML(t *testing.T) {
<runmode>dev</runmode>
<runmode>dev</runmode>
<autorender>false</autorender>
<autorender>false</autorender>
<copyrequestbody>true</copyrequestbody>
<copyrequestbody>true</copyrequestbody>
<path1>$$GO
ROOT
</path1>
<path1>$$GO
PATH
</path1>
<path2>$$GO
ROOT
||/home/go</path2>
<path2>$$GO
PATH
||/home/go</path2>
<path3>$$GO
ROOT
$$GOPATH2||/home/go</path3>
<path3>$$GO
PATH
$$GOPATH2||/home/go</path3>
<token1>$$TOKEN</token1>
<token1>$$TOKEN</token1>
<token2>$$TOKEN||</token2>
<token2>$$TOKEN||</token2>
<token3>$$TOKEN||astaxie</token3>
<token3>$$TOKEN||astaxie</token3>
...
@@ -53,8 +53,8 @@ func TestXML(t *testing.T) {
...
@@ -53,8 +53,8 @@ func TestXML(t *testing.T) {
"runmode"
:
"dev"
,
"runmode"
:
"dev"
,
"autorender"
:
false
,
"autorender"
:
false
,
"copyrequestbody"
:
true
,
"copyrequestbody"
:
true
,
"path1"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path1"
:
os
.
Getenv
(
"GO
PATH
"
),
"path2"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path2"
:
os
.
Getenv
(
"GO
PATH
"
),
"path3"
:
"/home/go"
,
"path3"
:
"/home/go"
,
"token1"
:
""
,
"token1"
:
""
,
"token2"
:
""
,
"token2"
:
""
,
...
...
config/yaml/yaml_test.go
View file @
1b04571c
...
@@ -33,10 +33,10 @@ func TestYaml(t *testing.T) {
...
@@ -33,10 +33,10 @@ func TestYaml(t *testing.T) {
"runmode": dev
"runmode": dev
"autorender": false
"autorender": false
"copyrequestbody": true
"copyrequestbody": true
"PATH": GO
ROOT
"PATH": GO
PATH
"path1": $$GO
ROOT
"path1": $$GO
PATH
"path2": $$GO
ROOT
||/home/go
"path2": $$GO
PATH
||/home/go
"path3": $$GO
ROOT
$$GOPATH2||/home/go
"path3": $$GO
PATH
$$GOPATH2||/home/go
"token1": $$TOKEN
"token1": $$TOKEN
"token2": $$TOKEN||
"token2": $$TOKEN||
"token3": $$TOKEN||astaxie
"token3": $$TOKEN||astaxie
...
@@ -53,9 +53,9 @@ func TestYaml(t *testing.T) {
...
@@ -53,9 +53,9 @@ func TestYaml(t *testing.T) {
"runmode"
:
"dev"
,
"runmode"
:
"dev"
,
"autorender"
:
false
,
"autorender"
:
false
,
"copyrequestbody"
:
true
,
"copyrequestbody"
:
true
,
"PATH"
:
"GO
ROOT
"
,
"PATH"
:
"GO
PATH
"
,
"path1"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path1"
:
os
.
Getenv
(
"GO
PATH
"
),
"path2"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path2"
:
os
.
Getenv
(
"GO
PATH
"
),
"path3"
:
"/home/go"
,
"path3"
:
"/home/go"
,
"token1"
:
""
,
"token1"
:
""
,
"token2"
:
""
,
"token2"
:
""
,
...
...
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