Cleanup linter warnings

This commit is contained in:
Gabe Kangas 2021-07-19 23:37:06 -07:00
parent 4d64539b07
commit 44d6a36b77
8 changed files with 35 additions and 20 deletions

View file

@ -23,3 +23,8 @@ linters:
- unconvert - unconvert
- unparam - unparam
- whitespace - whitespace
linters-settings:
govet:
disable:
- composites

View file

@ -448,7 +448,10 @@ func SetS3Configuration(w http.ResponseWriter, r *http.Request) {
} }
} }
data.SetS3Config(newS3Config.Value) if err := data.SetS3Config(newS3Config.Value); err != nil {
controllers.WriteSimpleResponse(w, false, err.Error())
return
}
controllers.WriteSimpleResponse(w, true, "storage configuration changed") controllers.WriteSimpleResponse(w, true, "storage configuration changed")
} }
@ -514,7 +517,10 @@ func SetChatDisabled(w http.ResponseWriter, r *http.Request) {
return return
} }
data.SetChatDisabled(configValue.Value.(bool)) if err := data.SetChatDisabled(configValue.Value.(bool)); err != nil {
controllers.WriteSimpleResponse(w, false, err.Error())
return
}
controllers.WriteSimpleResponse(w, true, "chat disabled status updated") controllers.WriteSimpleResponse(w, true, "chat disabled status updated")
} }
@ -567,7 +573,10 @@ func SetCustomStyles(w http.ResponseWriter, r *http.Request) {
return return
} }
data.SetCustomStyles(customStyles.Value.(string)) if err := data.SetCustomStyles(customStyles.Value.(string)); err != nil {
controllers.WriteSimpleResponse(w, false, err.Error())
return
}
controllers.WriteSimpleResponse(w, true, "custom styles updated") controllers.WriteSimpleResponse(w, true, "custom styles updated")
} }

View file

@ -5,11 +5,8 @@ import (
"sort" "sort"
"github.com/owncast/owncast/core/data" "github.com/owncast/owncast/core/data"
"github.com/owncast/owncast/models"
) )
type variants []models.StreamOutputVariant
type variantsResponse struct { type variantsResponse struct {
Name string `json:"name"` Name string `json:"name"`
Index int `json:"index"` Index int `json:"index"`

View file

@ -22,9 +22,7 @@ func setupStats() error {
statsSaveTimer := time.NewTicker(1 * time.Minute) statsSaveTimer := time.NewTicker(1 * time.Minute)
go func() { go func() {
for range statsSaveTimer.C { for range statsSaveTimer.C {
if err := saveStats(); err != nil { saveStats()
panic(err)
}
} }
}() }()
@ -112,7 +110,7 @@ func pruneViewerCount() {
_stats.Viewers = viewers _stats.Viewers = viewers
} }
func saveStats() error { func saveStats() {
if err := data.SetPeakOverallViewerCount(_stats.OverallMaxViewerCount); err != nil { if err := data.SetPeakOverallViewerCount(_stats.OverallMaxViewerCount); err != nil {
log.Errorln("error saving viewer count", err) log.Errorln("error saving viewer count", err)
} }
@ -124,8 +122,6 @@ func saveStats() error {
log.Errorln("error saving disconnect time", err) log.Errorln("error saving disconnect time", err)
} }
} }
return nil
} }
func getSavedStats() models.Stats { func getSavedStats() models.Stats {

View file

@ -45,7 +45,7 @@ func (c *Libx264Codec) GlobalFlags() string {
} }
func (c *Libx264Codec) PixelFormat() string { func (c *Libx264Codec) PixelFormat() string {
return "yuv420p" return "yuv420p" //nolint:goconst
} }
func (c *Libx264Codec) ExtraArguments() string { func (c *Libx264Codec) ExtraArguments() string {
@ -78,7 +78,7 @@ func (c *Libx264Codec) GetPresetForLevel(l int) string {
} }
if l >= len(presetMapping) { if l >= len(presetMapping) {
return "superfast" return "superfast" //nolint:goconst
} }
return presetMapping[l] return presetMapping[l]

12
main.go
View file

@ -98,21 +98,27 @@ func main() {
} }
log.Println("Saving new web server port number to", portNumber) log.Println("Saving new web server port number to", portNumber)
data.SetHTTPPortNumber(float64(portNumber)) if err := data.SetHTTPPortNumber(float64(portNumber)); err != nil {
log.Errorln(err)
}
} }
config.WebServerPort = data.GetHTTPPortNumber() config.WebServerPort = data.GetHTTPPortNumber()
// Set the web server ip // Set the web server ip
if *webServerIPOverride != "" { if *webServerIPOverride != "" {
log.Println("Saving new web server listen IP address to", *webServerIPOverride) log.Println("Saving new web server listen IP address to", *webServerIPOverride)
data.SetHTTPListenAddress(string(*webServerIPOverride)) if err := data.SetHTTPListenAddress(*webServerIPOverride); err != nil {
log.Errorln(err)
}
} }
config.WebServerIP = data.GetHTTPListenAddress() config.WebServerIP = data.GetHTTPListenAddress()
// Set the rtmp server port // Set the rtmp server port
if *rtmpPortOverride > 0 { if *rtmpPortOverride > 0 {
log.Println("Saving new RTMP server port number to", *rtmpPortOverride) log.Println("Saving new RTMP server port number to", *rtmpPortOverride)
data.SetRTMPPortNumber(float64(*rtmpPortOverride)) if err := data.SetRTMPPortNumber(float64(*rtmpPortOverride)); err != nil {
log.Errorln(err)
}
} }
// starts the core // starts the core

View file

@ -128,7 +128,9 @@ func (yp *YP) ping() {
_inErrorState = false _inErrorState = false
if pingResponse.Key != key { if pingResponse.Key != key {
data.SetDirectoryRegistrationKey(key) if err := data.SetDirectoryRegistrationKey(key); err != nil {
log.Errorln("unable to save directory key:", err)
}
} }
} }