From 69a5eeb7b67f013168f9ceef61b3f2af243aa96e Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Fri, 30 Aug 2019 12:30:30 +0200 Subject: [PATCH] [golangci-lint] Changed formatting. --- feed-to-muc.go | 12 ++++++------ getarticles.go | 9 ++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/feed-to-muc.go b/feed-to-muc.go index e295838..347273f 100644 --- a/feed-to-muc.go +++ b/feed-to-muc.go @@ -189,15 +189,15 @@ func pingMUC(client *xmpp.Client, botJid string, muc string, mucNick string) { pingReceived = false // Check for result IQ as long as there was no reply yet. - for (time.Since(pingSent).Seconds() < 10.0) && (pingReceived == false) { + for (time.Since(pingSent).Seconds() < 10.0) && (!pingReceived) { time.Sleep(1 * time.Second) - if pingReceived == true { + if pingReceived { break } } // Quit if no ping reply was received. - if pingReceived == false { + if !pingReceived { log.Fatal("MUC not available.") } } @@ -232,7 +232,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str // Check for room mention of the bots nick if the the message type is groupchat. if v.Type == "groupchat" { // Leave if option quiet is set. - if quiet == true { + if quiet { break } // Get first word of the message and transform it to lower case. @@ -384,7 +384,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str if v.Type == "get" { // Reply to disco#info requests according to https://xmpp.org/extensions/xep-0030.html. if strings.Contains(string(v.Query), - "") == true { + "") { _, err := client.RawInformation(client.JID(), v.From, v.ID, "result", ""+ ""+ @@ -392,7 +392,7 @@ func processStanzas(client *xmpp.Client, muc string, mucNick string, feeds []str if err != nil { log.Fatal("Error: Failed to reply to disco#info:", err) } - } else if strings.Contains(string(v.Query), "") == true { + } else if strings.Contains(string(v.Query), "") { // Reply to pings. _, err := client.RawInformation(client.JID(), v.From, v.ID, "result", "") if err != nil { diff --git a/getarticles.go b/getarticles.go index d1dba1c..ac1b0c6 100644 --- a/getarticles.go +++ b/getarticles.go @@ -13,8 +13,8 @@ import ( "strings" "time" - "github.com/mmcdole/gofeed" "github.com/jaytaylor/html2text" + "github.com/mmcdole/gofeed" ) // Get new articles for specified feed. @@ -70,7 +70,10 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) { // Create a hash as identifier for the feed. // The identifier will be used as filename for caching the update time. h := fnv.New32a() - h.Write([]byte(feedURL)) + _, err := h.Write([]byte(feedURL)) + if err != nil { + log.Fatal("Error: Can't create hash for", feedURL+":", err) + } if _, err := os.Stat(cachePath); os.IsNotExist(err) { err = os.MkdirAll(cachePath, 0700) if err != nil { @@ -167,7 +170,7 @@ func getArticles(feedURL string, max int, noExcerpt bool) (string, error) { // Note: Checking for cached timestamp being newer, instead of not older // lead to duplicate messages for the same article. Probably a corner // case when the time is identical. - if last.Before(updateTime) == false { + if !last.Before(updateTime) { continue }