Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

Commit

Permalink
Fix relative path exec binary
Browse files Browse the repository at this point in the history
Signed-off-by: Valentin Pichard <[email protected]>
  • Loading branch information
Valentin Pichard committed Jan 4, 2019
1 parent 221c3b1 commit b2085c3
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package config

import v "github.com/spf13/viper"
import (
"os"
"path/filepath"

v "github.com/spf13/viper"
)

// InitConfig load config from file and/or the environment.
func InitConfig() error {
Expand All @@ -9,5 +14,11 @@ func InitConfig() error {
v.AddConfigPath("$HOME")
v.AddConfigPath(".")

dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
return err
}
v.AddConfigPath(dir)

return v.ReadInConfig()
}

0 comments on commit b2085c3

Please sign in to comment.