diff options
author | matthieu <matthieu.cneude@gmail.com> | 2020-07-03 07:15:22 +0200 |
---|---|---|
committer | matthieu <matthieu.cneude@gmail.com> | 2020-07-03 07:15:22 +0200 |
commit | 7b82e06f82bf3282910cd32fce3c362427132c6b (patch) | |
tree | e893b9c3b4d4408ea9478ff4a2a93288bd2b1627 | |
parent | fbe355faee02f19af438d69cca5d8dfdbce7e251 (diff) |
Begin to improve file search through different path
-rw-r--r-- | internal/platform/ga.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/platform/ga.go b/internal/platform/ga.go index 1fdc99b..d8b2435 100644 --- a/internal/platform/ga.go +++ b/internal/platform/ga.go @@ -7,6 +7,7 @@ import ( "strconv" "strings" + "github.com/mitchellh/go-homedir" "github.com/pkg/errors" "golang.org/x/oauth2/google" "golang.org/x/oauth2/jwt" @@ -95,9 +96,14 @@ type AnalyticValues struct { // NewAnalyticsClient to connect to Google Analytics APIs. func NewAnalyticsClient(keyfile string) (*Analytics, error) { + // TODO generalize file opening by looking in the different possible folders (see trello ticket) data, err := ioutil.ReadFile(keyfile) if err != nil { - return nil, fmt.Errorf("reading keyfile %q failed: %v", keyfile, err) + home, _ := homedir.Dir() + data, err = ioutil.ReadFile(home + "/.config/devdash/" + keyfile) + if err != nil { + return nil, fmt.Errorf("reading keyfile %q failed: %v", keyfile, err) + } } an := &Analytics{} |