chore(go): run betteralign and gofumpt on codebase

This commit is contained in:
Gabe Kangas
2023-10-08 14:22:28 -07:00
parent a31179b604
commit 8e79e2acfa
18 changed files with 73 additions and 61 deletions

View File

@@ -622,8 +622,8 @@ func VerifySettings() error {
// FindHighestVideoQualityIndex will return the highest quality from a slice of variants.
func FindHighestVideoQualityIndex(qualities []models.StreamOutputVariant) int {
type IndexedQuality struct {
index int
quality models.StreamOutputVariant
index int
}
if len(qualities) < 2 {
@@ -632,7 +632,7 @@ func FindHighestVideoQualityIndex(qualities []models.StreamOutputVariant) int {
indexedQualities := make([]IndexedQuality, 0)
for index, quality := range qualities {
indexedQuality := IndexedQuality{index, quality}
indexedQuality := IndexedQuality{quality, index}
indexedQualities = append(indexedQualities, indexedQuality)
}

View File

@@ -8,8 +8,8 @@ import (
// ConfigEntry is the actual object saved to the database.
// The Value is encoded using encoding/gob.
type ConfigEntry struct {
Key string
Value interface{}
Key string
}
func (c *ConfigEntry) getStringSlice() ([]string, error) {

View File

@@ -20,6 +20,8 @@ func TestString(t *testing.T) {
const testKey = "test string key"
const testValue = "test string value"
fmt.Println(testKey, testValue)
if err := _datastore.SetString(testKey, testValue); err != nil {
panic(err)
}
@@ -87,7 +89,7 @@ func TestCustomType(t *testing.T) {
}
// Save config entry to the database
if err := _datastore.Save(ConfigEntry{testKey, &testStruct}); err != nil {
if err := _datastore.Save(ConfigEntry{&testStruct, testKey}); err != nil {
t.Error(err)
}
@@ -119,7 +121,7 @@ func TestStringMap(t *testing.T) {
}
// Save config entry to the database
if err := _datastore.Save(ConfigEntry{testKey, &testMap}); err != nil {
if err := _datastore.Save(ConfigEntry{&testMap, testKey}); err != nil {
t.Error(err)
}

View File

@@ -17,9 +17,11 @@ import (
log "github.com/sirupsen/logrus"
)
var emojiCacheMu sync.Mutex
var emojiCacheData = make([]models.CustomEmoji, 0)
var emojiCacheModTime time.Time
var (
emojiCacheMu sync.Mutex
emojiCacheData = make([]models.CustomEmoji, 0)
emojiCacheModTime time.Time
)
// UpdateEmojiList will update the cache (if required) and
// return the modifiation time.

View File

@@ -11,7 +11,7 @@ func (ds *Datastore) GetStringSlice(key string) ([]string, error) {
// SetStringSlice will set the string slice value for a key.
func (ds *Datastore) SetStringSlice(key string, value []string) error {
configEntry := ConfigEntry{key, value}
configEntry := ConfigEntry{value, key}
return ds.Save(configEntry)
}
@@ -26,7 +26,7 @@ func (ds *Datastore) GetString(key string) (string, error) {
// SetString will set the string value for a key.
func (ds *Datastore) SetString(key string, value string) error {
configEntry := ConfigEntry{key, value}
configEntry := ConfigEntry{value, key}
return ds.Save(configEntry)
}
@@ -41,7 +41,7 @@ func (ds *Datastore) GetNumber(key string) (float64, error) {
// SetNumber will set the numeric value for a key.
func (ds *Datastore) SetNumber(key string, value float64) error {
configEntry := ConfigEntry{key, value}
configEntry := ConfigEntry{value, key}
return ds.Save(configEntry)
}
@@ -56,7 +56,7 @@ func (ds *Datastore) GetBool(key string) (bool, error) {
// SetBool will set the boolean value for a key.
func (ds *Datastore) SetBool(key string, value bool) error {
configEntry := ConfigEntry{key, value}
configEntry := ConfigEntry{value, key}
return ds.Save(configEntry)
}
@@ -71,6 +71,6 @@ func (ds *Datastore) GetStringMap(key string) (map[string]string, error) {
// SetStringMap will set the string map value for a key.
func (ds *Datastore) SetStringMap(key string, value map[string]string) error {
configEntry := ConfigEntry{key, value}
configEntry := ConfigEntry{value, key}
return ds.Save(configEntry)
}