Skip to content

Commit

Permalink
Lookup .wegorc in $WEGORC
Browse files Browse the repository at this point in the history
Check for .wegorc in $WEGORC first before looking up in user.Current().HomeDir.
  • Loading branch information
difro committed May 27, 2015
1 parent e0dce56 commit 8b08d13
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions we.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,15 +479,18 @@ func printDay(w weather) (ret []string) {
}

func init() {
usr, err := user.Current()
if err != nil {
log.Fatal(err)
configpath = os.Getenv("WEGORC")
if configpath == "" {
usr, err := user.Current()
if err != nil {
log.Fatal(err)
}
configpath = path.Join(usr.HomeDir, ".wegorc")
}
configpath = path.Join(usr.HomeDir, ".wegorc")
config.APIKey = ""
config.City = "New York"
config.Imperial = false
err = configload()
err := configload()
if _, ok := err.(*os.PathError); ok {
log.Printf("No config file found. Creating %s ...", configpath)
if err := configsave(); err != nil {
Expand Down

0 comments on commit 8b08d13

Please sign in to comment.