From 9a9a6060f2058f7a2e8ec0ef33d90f9f3bff6109 Mon Sep 17 00:00:00 2001 From: Cenk Alti Date: Tue, 19 Mar 2019 15:15:38 +0300 Subject: [PATCH] discard error on hash.Write --- internal/analytics/analytics.go | 6 +++--- internal/analytics/analytics_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/analytics/analytics.go b/internal/analytics/analytics.go index 815c57e..53ca12e 100644 --- a/internal/analytics/analytics.go +++ b/internal/analytics/analytics.go @@ -44,7 +44,7 @@ func (p *Analytics) InsertEvents(events []event.Event) (n int, err error) { e.IsAnonymous = true } else { hash.Reset() - hash.Write([]byte(e.UserID)) + _, _ = hash.Write([]byte(e.UserID)) if hex.EncodeToString(hash.Sum(nil)) != *e.UserHash { err = errors.New("invalid user hash: " + *e.UserHash) return @@ -64,7 +64,7 @@ func (p *Analytics) UpdateUsers(users []user.User) (n int, err error) { now := time.Now().UTC() for _, u := range users { hash.Reset() - hash.Write([]byte(u.ID)) + _, _ = hash.Write([]byte(u.ID)) if hex.EncodeToString(hash.Sum(nil)) != u.Hash { err = errors.New("invalid hash: " + u.Hash) return @@ -98,7 +98,7 @@ func (p *Analytics) Health() error { func (p *Analytics) Alias(previousID, userID user.ID, userHash string) error { hash := hmac.New(sha256.New, p.secret) - hash.Write([]byte(userID)) + _, _ = hash.Write([]byte(userID)) if hex.EncodeToString(hash.Sum(nil)) != userHash { return errors.New("invalid hash: " + userHash) } diff --git a/internal/analytics/analytics_test.go b/internal/analytics/analytics_test.go index 0141bd0..9956499 100644 --- a/internal/analytics/analytics_test.go +++ b/internal/analytics/analytics_test.go @@ -194,6 +194,6 @@ func TestAlias(t *testing.T) { func generateUserHash(userID, secret string) string { hash := hmac.New(sha256.New, []byte(secret)) - hash.Write([]byte(userID)) + _, _ = hash.Write([]byte(userID)) return hex.EncodeToString(hash.Sum(nil)) }