Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
haoqu.ma
/
gotty
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 25a5bc0b
authored
Aug 28, 2015
by
Iwasaki Yudai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix default config file loading
1 parent
8e90497c
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
app/app.go
main.go
app/app.go
View file @
25a5bc0
...
@@ -106,7 +106,7 @@ func ApplyConfigFile(options *Options, configFilePath string) error {
...
@@ -106,7 +106,7 @@ func ApplyConfigFile(options *Options, configFilePath string) error {
}
}
func
applyConfigFile
(
options
*
Options
,
filePath
string
)
error
{
func
applyConfigFile
(
options
*
Options
,
filePath
string
)
error
{
filePath
=
e
xpandHomeDir
(
filePath
)
filePath
=
E
xpandHomeDir
(
filePath
)
if
_
,
err
:=
os
.
Stat
(
filePath
);
os
.
IsNotExist
(
err
)
{
if
_
,
err
:=
os
.
Stat
(
filePath
);
os
.
IsNotExist
(
err
)
{
return
err
return
err
}
}
...
@@ -138,7 +138,7 @@ func applyConfigFile(options *Options, filePath string) error {
...
@@ -138,7 +138,7 @@ func applyConfigFile(options *Options, filePath string) error {
return
nil
return
nil
}
}
func
e
xpandHomeDir
(
path
string
)
string
{
func
E
xpandHomeDir
(
path
string
)
string
{
if
path
[
0
:
2
]
==
"~/"
{
if
path
[
0
:
2
]
==
"~/"
{
return
os
.
Getenv
(
"HOME"
)
+
path
[
1
:
]
return
os
.
Getenv
(
"HOME"
)
+
path
[
1
:
]
}
else
{
}
else
{
...
@@ -234,8 +234,8 @@ func (app *App) Run() error {
...
@@ -234,8 +234,8 @@ func (app *App) Run() error {
)
)
if
app
.
options
.
EnableTLS
{
if
app
.
options
.
EnableTLS
{
err
=
app
.
server
.
ListenAndServeTLS
(
err
=
app
.
server
.
ListenAndServeTLS
(
e
xpandHomeDir
(
app
.
options
.
TLSCrtFile
),
E
xpandHomeDir
(
app
.
options
.
TLSCrtFile
),
e
xpandHomeDir
(
app
.
options
.
TLSKeyFile
),
E
xpandHomeDir
(
app
.
options
.
TLSKeyFile
),
)
)
}
else
{
}
else
{
err
=
app
.
server
.
ListenAndServe
()
err
=
app
.
server
.
ListenAndServe
()
...
...
main.go
View file @
25a5bc0
...
@@ -69,7 +69,7 @@ func main() {
...
@@ -69,7 +69,7 @@ func main() {
options
:=
app
.
DefaultOptions
options
:=
app
.
DefaultOptions
configFile
:=
c
.
String
(
"config"
)
configFile
:=
c
.
String
(
"config"
)
_
,
err
:=
os
.
Stat
(
configFile
)
_
,
err
:=
os
.
Stat
(
app
.
ExpandHomeDir
(
configFile
)
)
if
configFile
!=
"~/.gotty"
||
!
os
.
IsNotExist
(
err
)
{
if
configFile
!=
"~/.gotty"
||
!
os
.
IsNotExist
(
err
)
{
if
err
:=
app
.
ApplyConfigFile
(
&
options
,
configFile
);
err
!=
nil
{
if
err
:=
app
.
ApplyConfigFile
(
&
options
,
configFile
);
err
!=
nil
{
exit
(
err
,
2
)
exit
(
err
,
2
)
...
@@ -101,7 +101,9 @@ func main() {
...
@@ -101,7 +101,9 @@ func main() {
}
}
func
exit
(
err
error
,
code
int
)
{
func
exit
(
err
error
,
code
int
)
{
if
err
!=
nil
{
fmt
.
Println
(
err
)
fmt
.
Println
(
err
)
}
os
.
Exit
(
code
)
os
.
Exit
(
code
)
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment