Skip to content

Commit f7abb85

Browse files
author
coder2z
committed
配置优化
1 parent 8d2d527 commit f7abb85

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-0
lines changed

xcfg/file/config.toml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[app]
2+
AppName = "testCyj"
3+
4+
[server]
5+
ip="0.0.0.0"
6+
port=1234
7+
locale = "zh"
8+
9+
[mysql.main]
10+
tablePrefix = "testCyj"
11+
host = "127.0.0.1"
12+
username = "root"
13+
password = "root"
14+
dbName = "testCyj"
15+
type = "mysql"
16+
port = "3306"
17+
debug = true
18+
19+
[redis.main]
20+
addr = "127.0.0.1:6379"
21+
22+
[email.main]
23+
host = "smtp.yeah.net"
24+
port = 465
25+
username = ""
26+
password = ""
27+
28+
[sms.main]
29+
area = "cn-hangzhou"
30+
accessKeyId = ""
31+
accessSecret = ""
32+
33+
[xlog]
34+
name = "testCyj.log"
35+
dir = "."
36+
level = ""
37+
async = false
38+
debug = true
39+
add_caller= true
40+
caller_skip=2
41+
42+
[app.govern]
43+
host = "127.0.0.1"
44+
port = 4569
45+
46+
[trace.jaeger]
47+
[trace.jaeger.reporter]
48+
localAgentHostPort = "127.0.0.1:6831"

xcfg/file/file_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package file
2+
3+
import (
4+
"github.com/coder2z/g-saber/xcfg"
5+
"testing"
6+
)
7+
8+
func TestNewDataSource(t *testing.T) {
9+
err := xcfg.LoadFromConfigAddr("config.toml")
10+
if err != nil {
11+
t.Log(err)
12+
return
13+
}
14+
t.Log(xcfg.Get("app"))
15+
}
16+

0 commit comments

Comments
 (0)