Skip to content

Commit

Permalink
Move flag define to main package
Browse files Browse the repository at this point in the history
  • Loading branch information
xwjdsh committed Dec 1, 2017
1 parent 1a43cb0 commit 5222454
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package main

import (
"flag"

"github.com/gin-gonic/gin"
"github.com/go-ignite/ignite-admin/controllers"
"github.com/go-ignite/ignite-admin/jobs"
Expand All @@ -10,8 +12,10 @@ import (
"github.com/robfig/cron"
)

var confPath = flag.String("c", "./conf/config.toml", "config file")

func main() {
utility.InitConf()
utility.InitConf(*confPath)
db := utils.InitDB(utility.DB_Driver, utility.DB_Connect)
go initRouter(db)
go initJob(db)
Expand Down
11 changes: 3 additions & 8 deletions utils/conf.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package utils

import (
"flag"
"fmt"
"os"

toml "github.com/pelletier/go-toml"
)

var (
confPath = flag.String("c", "./conf/config.toml", "config file")
)

var (
// for app config
APP_Address string
Expand All @@ -23,10 +18,10 @@ var (
Auth_Username, Auth_Password, Auth_Secret string
)

func InitConf() {
func InitConf(confPath string) {
//Check config file
if _, err := os.Stat(*confPath); !os.IsNotExist(err) {
if config, err := toml.LoadFile(*confPath); err == nil {
if _, err := os.Stat(confPath); !os.IsNotExist(err) {
if config, err := toml.LoadFile(confPath); err == nil {
APP_Address = config.Get("app.address").(string)

DB_Driver = config.Get("db.driver").(string)
Expand Down
11 changes: 3 additions & 8 deletions vendor/github.com/go-ignite/ignite/utils/conf.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@
"revisionTime": "2017-12-01T14:07:45Z"
},
{
"checksumSHA1": "eTnn0UOtxPMk3AqR+HJ0CbYT+hg=",
"checksumSHA1": "1PdlH+bjqdkzObppzHkiBL3FPvk=",
"path": "github.com/go-ignite/ignite/utils",
"revision": "5933e18a5f8a4c90b5a5440cbf59bf9f16b3dce2",
"revisionTime": "2017-12-01T14:07:45Z"
"revision": "cb49cb14c11344122d56835302ba20bb79c55357",
"revisionTime": "2017-12-01T16:26:16Z"
},
{
"checksumSHA1": "QD6LqgLz2JMxXqns8TaxtK9AuHs=",
Expand Down

0 comments on commit 5222454

Please sign in to comment.