From 40ee7ebd8000560ef75a968ad69f6e67d0142f59 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Wed, 13 Dec 2017 09:45:15 -0500 Subject: [PATCH] storing in redis, not storing newline --- cmd/version-scraper/main.go | 15 +++++++++++---- herald.go | 5 +++-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/version-scraper/main.go b/cmd/version-scraper/main.go index 4d0b0e2..49f7876 100644 --- a/cmd/version-scraper/main.go +++ b/cmd/version-scraper/main.go @@ -4,8 +4,7 @@ import "github.com/heroku/herald" import "github.com/fatih/color" import "time" import "log" - - +import "fmt" func main() { @@ -49,9 +48,17 @@ func main() { // Execute the executable, print the results. results := exe.Execute() - // for _, result := range(results) { + for _, result := range(results) { + key := fmt.Sprintf("%s:%s:%s", bp, exe, result) + value := "UNKNOWN" - // } + // Store the results in Redis. + _, err := redis.Do("SETNX", key, value) + if err != nil { + log.Fatal(err) + } + + } // Log results. log.Printf("%s:%s results: %s", red(bp), magenta(exe), results) diff --git a/herald.go b/herald.go index 435bd97..767ca4b 100644 --- a/herald.go +++ b/herald.go @@ -26,9 +26,10 @@ func RedisConnect() redis.Conn { // Fail epically. log.Fatal(err) } - defer c.Close() + // defer c.Close() return c + } // TODO: Maybe remove. @@ -70,7 +71,7 @@ func (e Executable) Execute() []string { // TODO: Update this to return, etc. log.Fatal(err) } - return strings.Split(string(out), "\n") + return strings.Split(strings.Trim(string(out), "\n"), "\n") }