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
- unparam
- 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")
}
@ -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")
}

View File

@ -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"`

View File

@ -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)

View File

@ -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 {

View File

@ -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]

12
main.go
View File

@ -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

View File

@ -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)
}
}
}