Archived
1
0
Fork 0

Use array of key/value for Twitter hashtags (#1)

With Go, maps are not ordered the way they are declared. Keys can be read at any
order. When a pattern is too large ("rtx 3060"), when placed first, it can match
a name of another product ("rtx 3060 ti"). When placed second, the good hashtag
is chosen. This commit uses an array of maps because arrays are ordered.

Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
Julien Riou 2021-02-27 18:31:11 +01:00
commit 4342f65211
No known key found for this signature in database
GPG key ID: FF42D23B580C89F7
4 changed files with 26 additions and 24 deletions

View file

@ -16,11 +16,11 @@ type Config struct {
// TwitterConfig to store Twitter API secrets
type TwitterConfig struct {
ConsumerKey string `json:"consumer_key"`
ConsumerSecret string `json:"consumer_secret"`
AccessToken string `json:"access_token"`
AccessTokenSecret string `json:"access_token_secret"`
Hashtags map[string]string `json:"hashtags"`
ConsumerKey string `json:"consumer_key"`
ConsumerSecret string `json:"consumer_secret"`
AccessToken string `json:"access_token"`
AccessTokenSecret string `json:"access_token_secret"`
Hashtags []map[string]string `json:"hashtags"`
}
// NewConfig creates a Config struct