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{} {
//
// It accept value formats "$$env" , "$$env||" , "$$env||defaultValue" , "defaultvalue".
// 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/".
// v3 := config.ChooseRealValue("Astaxie") // return the value "Astaxie".
func
ChooseRealValue
(
value
string
)
(
realValue
string
)
{
...
...
config/ini_test.go
View file @
1b04571c
...
...
@@ -42,9 +42,9 @@ needlogin = ON
enableSession = Y
enableCookie = N
flag = 1
path1 = $$GO
ROOT
path2 = $$GO
ROOT
||/home/go
path3 = $$GO
ROOT
$$GOPATH2||/home/go
path1 = $$GO
PATH
path2 = $$GO
PATH
||/home/go
path3 = $$GO
PATH
$$GOPATH2||/home/go
token1 = $$TOKEN
token2 = $$TOKEN||
token3 = $$TOKEN||astaxie
...
...
@@ -55,7 +55,7 @@ key1="asta"
key2 = "xie"
CaseInsensitive = true
peers = one;two;three
password = $$GO
ROOT
password = $$GO
PATH
`
keyValue
=
map
[
string
]
interface
{}{
...
...
@@ -73,8 +73,8 @@ password = $$GOROOT
"enableSession"
:
true
,
"enableCookie"
:
false
,
"flag"
:
true
,
"path1"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path2"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path1"
:
os
.
Getenv
(
"GO
PATH
"
),
"path2"
:
os
.
Getenv
(
"GO
PATH
"
),
"path3"
:
"/home/go"
,
"token1"
:
""
,
"token2"
:
""
,
...
...
@@ -85,7 +85,7 @@ password = $$GOROOT
"demo::key2"
:
"xie"
,
"demo::CaseInsensitive"
:
true
,
"demo::peers"
:
[]
string
{
"one"
,
"two"
,
"three"
},
"demo::password"
:
os
.
Getenv
(
"GO
ROOT
"
),
"demo::password"
:
os
.
Getenv
(
"GO
PATH
"
),
"null"
:
""
,
"demo2::key1"
:
""
,
"error"
:
""
,
...
...
config/json_test.go
View file @
1b04571c
...
...
@@ -86,9 +86,9 @@ func TestJson(t *testing.T) {
"enableSession": "Y",
"enableCookie": "N",
"flag": 1,
"path1": "$$GO
ROOT
",
"path2": "$$GO
ROOT
||/home/go",
"path3": "$$GO
ROOT
$$GOPATH2||/home/go",
"path1": "$$GO
PATH
",
"path2": "$$GO
PATH
||/home/go",
"path3": "$$GO
PATH
$$GOPATH2||/home/go",
"token1": "$$TOKEN",
"token2": "$$TOKEN||",
"token3": "$$TOKEN||astaxie",
...
...
@@ -99,12 +99,12 @@ func TestJson(t *testing.T) {
"port": "port",
"database": "database",
"username": "username",
"password": "$$GO
ROOT
",
"password": "$$GO
PATH
",
"conns":{
"maxconnection":12,
"autoconnect":true,
"connectioninfo":"info",
"root": "$$GO
ROOT
"
"root": "$$GO
PATH
"
}
}
}`
...
...
@@ -124,8 +124,8 @@ func TestJson(t *testing.T) {
"enableSession"
:
true
,
"enableCookie"
:
false
,
"flag"
:
true
,
"path1"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path2"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path1"
:
os
.
Getenv
(
"GO
PATH
"
),
"path2"
:
os
.
Getenv
(
"GO
PATH
"
),
"path3"
:
"/home/go"
,
"token1"
:
""
,
"token2"
:
""
,
...
...
@@ -135,11 +135,11 @@ func TestJson(t *testing.T) {
"database::host"
:
"host"
,
"database::port"
:
"port"
,
"database::database"
:
"database"
,
"database::password"
:
os
.
Getenv
(
"GO
ROOT
"
),
"database::password"
:
os
.
Getenv
(
"GO
PATH
"
),
"database::conns::maxconnection"
:
12
,
"database::conns::autoconnect"
:
true
,
"database::conns::connectioninfo"
:
"info"
,
"database::conns::root"
:
os
.
Getenv
(
"GO
ROOT
"
),
"database::conns::root"
:
os
.
Getenv
(
"GO
PATH
"
),
"unknown"
:
""
,
}
)
...
...
config/xml/xml_test.go
View file @
1b04571c
...
...
@@ -35,9 +35,9 @@ func TestXML(t *testing.T) {
<runmode>dev</runmode>
<autorender>false</autorender>
<copyrequestbody>true</copyrequestbody>
<path1>$$GO
ROOT
</path1>
<path2>$$GO
ROOT
||/home/go</path2>
<path3>$$GO
ROOT
$$GOPATH2||/home/go</path3>
<path1>$$GO
PATH
</path1>
<path2>$$GO
PATH
||/home/go</path2>
<path3>$$GO
PATH
$$GOPATH2||/home/go</path3>
<token1>$$TOKEN</token1>
<token2>$$TOKEN||</token2>
<token3>$$TOKEN||astaxie</token3>
...
...
@@ -53,8 +53,8 @@ func TestXML(t *testing.T) {
"runmode"
:
"dev"
,
"autorender"
:
false
,
"copyrequestbody"
:
true
,
"path1"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path2"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path1"
:
os
.
Getenv
(
"GO
PATH
"
),
"path2"
:
os
.
Getenv
(
"GO
PATH
"
),
"path3"
:
"/home/go"
,
"token1"
:
""
,
"token2"
:
""
,
...
...
config/yaml/yaml_test.go
View file @
1b04571c
...
...
@@ -33,10 +33,10 @@ func TestYaml(t *testing.T) {
"runmode": dev
"autorender": false
"copyrequestbody": true
"PATH": GO
ROOT
"path1": $$GO
ROOT
"path2": $$GO
ROOT
||/home/go
"path3": $$GO
ROOT
$$GOPATH2||/home/go
"PATH": GO
PATH
"path1": $$GO
PATH
"path2": $$GO
PATH
||/home/go
"path3": $$GO
PATH
$$GOPATH2||/home/go
"token1": $$TOKEN
"token2": $$TOKEN||
"token3": $$TOKEN||astaxie
...
...
@@ -53,9 +53,9 @@ func TestYaml(t *testing.T) {
"runmode"
:
"dev"
,
"autorender"
:
false
,
"copyrequestbody"
:
true
,
"PATH"
:
"GO
ROOT
"
,
"path1"
:
os
.
Getenv
(
"GO
ROOT
"
),
"path2"
:
os
.
Getenv
(
"GO
ROOT
"
),
"PATH"
:
"GO
PATH
"
,
"path1"
:
os
.
Getenv
(
"GO
PATH
"
),
"path2"
:
os
.
Getenv
(
"GO
PATH
"
),
"path3"
:
"/home/go"
,
"token1"
:
""
,
"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