chore(go): run betteralign and gofumpt on codebase
This commit is contained in:
@@ -4,6 +4,6 @@ import "github.com/owncast/owncast/core/user"
|
||||
|
||||
// ConnectedClientInfo represents the information about a connected client.
|
||||
type ConnectedClientInfo struct {
|
||||
Event
|
||||
User *user.User `json:"user"`
|
||||
Event
|
||||
}
|
||||
|
||||
@@ -35,14 +35,14 @@ type Server struct {
|
||||
// unregister requests from clients.
|
||||
unregister chan uint // the ChatClient id
|
||||
|
||||
geoipClient *geoip.Client
|
||||
geoipClient *geoip.Client
|
||||
|
||||
// a map of user IDs and timers that fire for chat part messages.
|
||||
userPartedTimers map[string]*time.Ticker
|
||||
seq uint
|
||||
maxSocketConnectionLimit int64
|
||||
|
||||
mu sync.RWMutex
|
||||
|
||||
// a map of user IDs and timers that fire for chat part messages.
|
||||
userPartedTimers map[string]*time.Ticker
|
||||
}
|
||||
|
||||
// NewChat will return a new instance of the chat server.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -28,23 +28,25 @@ import (
|
||||
type S3Storage struct {
|
||||
sess *session.Session
|
||||
s3Client *s3.S3
|
||||
host string
|
||||
|
||||
s3Endpoint string
|
||||
s3ServingEndpoint string
|
||||
s3Region string
|
||||
s3Bucket string
|
||||
s3AccessKey string
|
||||
s3Secret string
|
||||
s3ACL string
|
||||
s3PathPrefix string
|
||||
s3ForcePathStyle bool
|
||||
uploader *s3manager.Uploader
|
||||
|
||||
// If we try to upload a playlist but it is not yet on disk
|
||||
// then keep a reference to it here.
|
||||
queuedPlaylistUpdates map[string]string
|
||||
|
||||
uploader *s3manager.Uploader
|
||||
s3Bucket string
|
||||
s3Region string
|
||||
s3ServingEndpoint string
|
||||
s3AccessKey string
|
||||
s3Secret string
|
||||
s3ACL string
|
||||
s3PathPrefix string
|
||||
|
||||
s3Endpoint string
|
||||
host string
|
||||
|
||||
s3ForcePathStyle bool
|
||||
}
|
||||
|
||||
// NewS3Storage returns a new S3Storage instance.
|
||||
@@ -330,6 +332,6 @@ func (s *S3Storage) retrieveAllVideoSegments() ([]s3object, error) {
|
||||
}
|
||||
|
||||
type s3object struct {
|
||||
key string
|
||||
lastModified time.Time
|
||||
key string
|
||||
}
|
||||
|
||||
@@ -13,8 +13,10 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var _lastTranscoderLogMessage = ""
|
||||
var l = &sync.RWMutex{}
|
||||
var (
|
||||
_lastTranscoderLogMessage = ""
|
||||
l = &sync.RWMutex{}
|
||||
)
|
||||
|
||||
var errorMap = map[string]string{
|
||||
"Unrecognized option 'vaapi_device'": "you are likely trying to utilize a vaapi codec, but your version of ffmpeg or your hardware doesn't support it. change your codec to libx264 and restart your stream",
|
||||
@@ -100,14 +102,14 @@ func createVariantDirectories() {
|
||||
|
||||
if len(data.GetStreamOutputVariants()) != 0 {
|
||||
for index := range data.GetStreamOutputVariants() {
|
||||
if err := os.MkdirAll(path.Join(config.HLSStoragePath, strconv.Itoa(index)), 0750); err != nil {
|
||||
if err := os.MkdirAll(path.Join(config.HLSStoragePath, strconv.Itoa(index)), 0o750); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dir := path.Join(config.HLSStoragePath, strconv.Itoa(0))
|
||||
log.Traceln("Creating", dir)
|
||||
if err := os.MkdirAll(dir, 0750); err != nil {
|
||||
if err := os.MkdirAll(dir, 0o750); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,9 +18,9 @@ var webhookWorkerPoolSize = runtime.GOMAXPROCS(0)
|
||||
|
||||
// Job struct bundling the webhook and the payload in one struct.
|
||||
type Job struct {
|
||||
webhook models.Webhook
|
||||
payload WebhookEvent
|
||||
wg *sync.WaitGroup
|
||||
payload WebhookEvent
|
||||
webhook models.Webhook
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -46,7 +46,7 @@ func initWorkerPool() {
|
||||
|
||||
func addToQueue(webhook models.Webhook, payload WebhookEvent, wg *sync.WaitGroup) {
|
||||
log.Tracef("Queued Event %s for Webhook %s", payload.Type, webhook.URL)
|
||||
queue <- Job{webhook, payload, wg}
|
||||
queue <- Job{wg, payload, webhook}
|
||||
}
|
||||
|
||||
func worker(workerID int, queue <-chan Job) {
|
||||
|
||||
Reference in New Issue
Block a user