Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
majora-go
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
majora
majora-go
Commits
40ba7541
Commit
40ba7541
authored
Jun 08, 2022
by
liguobao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 调整配置文件读取,适配Windows
parent
ba075fd5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
majora.yaml
conf/majora.yaml
+1
-1
config.go
initialize/config.go
+10
-1
No files found.
conf/majora.yaml
View file @
40ba7541
...
...
@@ -2,7 +2,7 @@ tunnel_addr: majora-vps.virjar.com:5879
dns_server
:
114.114.114.114:53
log_level
:
info
log_path
:
./majora-log/
daemon
:
true
#
daemon: true
reconn_interval
:
5s
#net_check_interval: 5s
net_check_url
:
https://www.baidu.com
...
...
initialize/config.go
View file @
40ba7541
package
initialize
import
(
"fmt"
"runtime"
"strings"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
)
...
...
@@ -27,8 +31,13 @@ func MustInitConfig(configFileName string, config interface{}) {
func
initConfig
(
configFileName
string
,
config
interface
{})
(
*
viper
.
Viper
,
error
)
{
if
configFileName
==
""
{
configFileName
=
"./conf/majora-dev.yaml"
configFileName
=
"./majora.yaml"
}
if
runtime
.
GOOS
==
"windows"
{
configFileName
=
strings
.
ReplaceAll
(
configFileName
,
"/"
,
"
\\
"
)
fmt
.
Printf
(
"run on Windows,configFileName:%s
\n
"
,
configFileName
)
}
fmt
.
Printf
(
"configFileName:%s
\n
"
,
configFileName
)
v
:=
viper
.
New
()
v
.
SetConfigFile
(
configFileName
)
err
:=
readAndUnmarshalConfig
(
v
,
config
)
...
...
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