Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
enoch
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps
enoch
Commits
83cc12bd
Commit
83cc12bd
authored
Mar 15, 2019
by
Node- 门 忠鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
# 修改环境变量获取方式
parent
6819e01a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
9 deletions
+5
-9
main.go
main.go
+4
-2
load_conf.go
service/conf/load_conf.go
+1
-7
No files found.
main.go
View file @
83cc12bd
...
@@ -14,12 +14,14 @@ import (
...
@@ -14,12 +14,14 @@ import (
)
)
func
main
()
{
func
main
()
{
conf
.
Init
()
var
port
string
var
port
string
var
quartz
bool
var
quartz
bool
flag
.
StringVar
(
&
port
,
"port"
,
conf
.
GlobalConfig
.
Port
,
"端口"
)
var
denv
string
flag
.
StringVar
(
&
port
,
"port"
,
"10086"
,
"端口"
)
flag
.
BoolVar
(
&
quartz
,
"quartz"
,
false
,
"quartz"
)
flag
.
BoolVar
(
&
quartz
,
"quartz"
,
false
,
"quartz"
)
flag
.
StringVar
(
&
denv
,
"env"
,
"dev"
,
"环境"
)
flag
.
Parse
()
flag
.
Parse
()
conf
.
Load
(
denv
)
file
,
err
:=
os
.
OpenFile
(
"quantgroup.log"
,
os
.
O_RDWR
|
os
.
O_CREATE
,
0666
)
file
,
err
:=
os
.
OpenFile
(
"quantgroup.log"
,
os
.
O_RDWR
|
os
.
O_CREATE
,
0666
)
defer
func
()
{
_
=
file
.
Close
()
}()
defer
func
()
{
_
=
file
.
Close
()
}()
...
...
service/conf/load_conf.go
View file @
83cc12bd
...
@@ -4,17 +4,11 @@ import (
...
@@ -4,17 +4,11 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"os"
)
)
var
GlobalConfig
=
Config
{}
var
GlobalConfig
=
Config
{}
func
Init
()
{
func
Load
(
denv
string
)
{
denv
:=
os
.
Getenv
(
"Denv"
)
if
""
==
denv
{
denv
=
"dev"
}
var
filename
=
"service/conf/"
+
denv
+
"/conf.json"
var
filename
=
"service/conf/"
+
denv
+
"/conf.json"
bytes
,
err
:=
ioutil
.
ReadFile
(
filename
)
bytes
,
err
:=
ioutil
.
ReadFile
(
filename
)
if
nil
!=
err
{
if
nil
!=
err
{
...
...
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