diff --git a/.travis.yml b/.travis.yml index 81ae154..f344c71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ install: - go get github.com/BurntSushi/toml - go get github.com/rakyll/statik - go get github.com/rakyll/statik/fs - - go get github.com/kr/beanstalk - go get -d -t -v ./... && go build -v ./... before_script: diff --git a/structs.go b/structs.go index 63ec2f4..fadfd5a 100644 --- a/structs.go +++ b/structs.go @@ -29,7 +29,7 @@ var ( selfConf SelfConf Stderr io.Writer = os.Stderr // Stderr is the io.Writer to which executed commands write standard error. Stdout io.Writer = os.Stdout // Stdout is the io.Writer to which executed commands write standard output. - ConfigFile = `.` + string(os.PathSeparator) + `aurora.toml` + ConfigFile = `aurora.toml` statisticsData = StatisticsData{new(sync.RWMutex), statisticsDataServer} statisticsDataServer = make(map[string]map[string]map[string]*list.List) notify = make(chan bool, 1) diff --git a/utils.go b/utils.go index d07b60f..de411fe 100644 --- a/utils.go +++ b/utils.go @@ -24,12 +24,8 @@ import ( // readConf read external config file when program startup. func readConf() error { buf := new(bytes.Buffer) - selfDir, err := filepath.Abs(filepath.Dir(os.Args[0])) - if err != nil { - return err - } if _, err := os.Stat(ConfigFile); os.IsNotExist(err) { - err := ioutil.WriteFile(selfDir+string(os.PathSeparator)+ConfigFile, []byte(ConfigFileTemplate), 0644) + err := ioutil.WriteFile(ConfigFile, []byte(ConfigFileTemplate), 0644) if err != nil { return err } @@ -152,7 +148,11 @@ func parseFlags() { helpPtr := flag.Bool("h", false, "Output this help and exit.") flag.Parse() if *configPtr == "" { - ConfigFile = `.` + string(os.PathSeparator) + `aurora.toml` + selfDir, err := filepath.Abs(filepath.Dir(os.Args[0])) + if err != nil { + os.Exit(0) + } + ConfigFile = selfDir + string(os.PathSeparator) + `aurora.toml` } else { ConfigFile = *configPtr }