Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
"sync"
)
Expand All @@ -28,7 +29,8 @@ type PushConfig struct {
}

var (
configFn = "./perfcounter.json"
configFile = "perfcounter.json"
configFn = "./" + configFile
defaultTags = ""
defaultStep = int64(60) //time in sec
defaultBases = []string{}
Expand All @@ -50,9 +52,15 @@ func config() *GlobalConfig {

func loadConfig() error {
if !isFileExist(configFn) {
return fmt.Errorf("config file not found: %s", configFn)
execPath, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
return fmt.Errorf("get exec path err: %s", err.Error())
}
configFn = filepath.Join(execPath, configFile)
if !isFileExist(configFn) {
return fmt.Errorf("config file not found: %s", configFn)
}
}

c, err := parseConfig(configFn)
if err != nil {
return err
Expand Down
5 changes: 4 additions & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package goperfcounter

// changelog:

// 0.0.2: Fix perfcounter.json and exec file in the same directory

// 0.0.1: init project
const (
VERSION = "0.0.1"
VERSION = "0.0.2"
)