Skip to content

Commit

Permalink
fix: ineffective assignments to err
Browse files Browse the repository at this point in the history
  • Loading branch information
zzzFelix committed Sep 27, 2023
1 parent 1cfa7b8 commit 1ac509e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions wbmalert.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,40 +65,49 @@ func initializeWebsites(configuration configuration) {
}

func createInitialSnapshot(website *website, ch chan struct{}) {
content, error := getWebsiteAsString(website)
if error == nil {
content, err := getWebsiteAsString(website)
if err == nil {
website.Snapshot = content
log.Println("Created initial snapshot for " + website.Name)
} else {
log.Println(err)
}
ch <- struct{}{}
}

func getWebsiteAsString(website *website) (string, error) {
request, err := http.NewRequest(http.MethodGet, website.Url, nil)
if err != nil {
return "Error", err
}
resp, err := client.Do(request)
if err != nil {
log.Println(err)
return "Error", err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return "Error", err
}
content := string(body[:])
content = removeByRegexp(content, website.RegexpRemove)
content = sanitizeHtml(content)
return content, nil
}

func checkWebsite(website *website, ch chan struct{}) {
content, error := getWebsiteAsString(website)
content, err := getWebsiteAsString(website)

if error == nil {
if err == nil {
if website.Snapshot != content {
website.Snapshot = content
printContentChangeMsg(website)
playSound()
} else {
log.Println("No changes for " + website.Name)
}
} else {
log.Println(err)
}

ch <- struct{}{}
Expand Down

0 comments on commit 1ac509e

Please sign in to comment.