diff --git a/.golangci.yml b/.golangci.yml index 0a17badeb..669bda5c3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -23,3 +23,8 @@ linters: - unconvert - unparam - whitespace + +linters-settings: + govet: + disable: + - composites diff --git a/controllers/admin/config.go b/controllers/admin/config.go index 471c22669..39a334555 100644 --- a/controllers/admin/config.go +++ b/controllers/admin/config.go @@ -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") } @@ -514,7 +517,10 @@ func SetChatDisabled(w http.ResponseWriter, r *http.Request) { 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") } @@ -567,7 +573,10 @@ func SetCustomStyles(w http.ResponseWriter, r *http.Request) { 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") } diff --git a/controllers/video.go b/controllers/video.go index 9f95c772b..537319579 100644 --- a/controllers/video.go +++ b/controllers/video.go @@ -5,11 +5,8 @@ import ( "sort" "github.com/owncast/owncast/core/data" - "github.com/owncast/owncast/models" ) -type variants []models.StreamOutputVariant - type variantsResponse struct { Name string `json:"name"` Index int `json:"index"` diff --git a/core/rtmp/rtmp.go b/core/rtmp/rtmp.go index bc089538e..e5311c001 100644 --- a/core/rtmp/rtmp.go +++ b/core/rtmp/rtmp.go @@ -80,8 +80,8 @@ func HandleConn(c *rtmp.Conn, nc net.Conn) { return } - rtmpOut, rtmpIn := io.Pipe() - _pipe = rtmpIn + rtmpOut, rtmpIn := io.Pipe() + _pipe = rtmpIn log.Infoln("Inbound stream connected.") _setStreamAsConnected(rtmpOut) diff --git a/core/stats.go b/core/stats.go index c63beaf40..639de1bc2 100644 --- a/core/stats.go +++ b/core/stats.go @@ -22,9 +22,7 @@ func setupStats() error { statsSaveTimer := time.NewTicker(1 * time.Minute) go func() { for range statsSaveTimer.C { - if err := saveStats(); err != nil { - panic(err) - } + saveStats() } }() @@ -112,7 +110,7 @@ func pruneViewerCount() { _stats.Viewers = viewers } -func saveStats() error { +func saveStats() { if err := data.SetPeakOverallViewerCount(_stats.OverallMaxViewerCount); err != nil { log.Errorln("error saving viewer count", err) } @@ -124,8 +122,6 @@ func saveStats() error { log.Errorln("error saving disconnect time", err) } } - - return nil } func getSavedStats() models.Stats { diff --git a/core/transcoder/codecs.go b/core/transcoder/codecs.go index dcfa6a50a..36e469e2b 100644 --- a/core/transcoder/codecs.go +++ b/core/transcoder/codecs.go @@ -45,7 +45,7 @@ func (c *Libx264Codec) GlobalFlags() string { } func (c *Libx264Codec) PixelFormat() string { - return "yuv420p" + return "yuv420p" //nolint:goconst } func (c *Libx264Codec) ExtraArguments() string { @@ -78,7 +78,7 @@ func (c *Libx264Codec) GetPresetForLevel(l int) string { } if l >= len(presetMapping) { - return "superfast" + return "superfast" //nolint:goconst } return presetMapping[l] diff --git a/main.go b/main.go index deab2dae5..351fabae0 100644 --- a/main.go +++ b/main.go @@ -98,21 +98,27 @@ func main() { } 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() // Set the web server ip if *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() // Set the rtmp server port if *rtmpPortOverride > 0 { 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 diff --git a/yp/yp.go b/yp/yp.go index 516a6e87c..1b3464ee0 100644 --- a/yp/yp.go +++ b/yp/yp.go @@ -128,7 +128,9 @@ func (yp *YP) ping() { _inErrorState = false if pingResponse.Key != key { - data.SetDirectoryRegistrationKey(key) + if err := data.SetDirectoryRegistrationKey(key); err != nil { + log.Errorln("unable to save directory key:", err) + } } }