From 4853ccc4f35988bb7eae407129d87d64956d99b9 Mon Sep 17 00:00:00 2001 From: b4b4r07 Date: Mon, 27 Nov 2017 13:14:45 +0900 Subject: [PATCH] Expand tilda --- main.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 65dabbf..9614a10 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,8 @@ import ( "os" "path/filepath" "strings" + + homedir "github.com/mitchellh/go-homedir" ) const ( @@ -34,16 +36,11 @@ func main() { dir, _ := configDir() json := filepath.Join(dir, "config.json") - err := cfg.LoadFile(json) - if err != nil { + if err := cfg.LoadFile(json); err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(1) } - credentials = os.Getenv(GoogleApplicationCredentials) - clientID = os.Getenv(IAPClientID) - binary = os.Getenv(IAPCurlBinary) - os.Exit(run(os.Args[1:])) } @@ -71,13 +68,11 @@ func run(args []string) int { env, err := cfg.GetEnv(url) if err != nil { fmt.Fprintf(os.Stderr, "Error: %s\n", err.Error()) - for _, url := range cfg.SimilarURLs(url) { - } - fmt.Fprintf(os.Stderr, " similar urls found %q\n") + fmt.Fprintf(os.Stderr, " similar urls found %q\n", cfg.SimilarURLs(url)) return 1 } if credentials == "" { - credentials = env.Credentials + credentials, _ = homedir.Expand(env.Credentials) } if clientID == "" { clientID = env.ClientID