Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

Some linter cleanup

Gabe Kangase801c0828ad4
diff --git a/config/config.go b/config/config.go
index 34c2c44275..a0b0673866 100644
--- a/config/config.go
+++ b/config/config.go
@@ -10,7 +10,7 @@ import (
// DatabaseFilePath is the path to the file ot be used as the global database for this run of the application.
var DatabaseFilePath = "data/owncast.db"
-// LogDirectory is the path to various log files
+// LogDirectory is the path to various log files.
var LogDirectory = "./data/logs"
// EnableDebugFeatures will print additional data to help in debugging.
diff --git a/config/verifyInstall.go b/config/verifyInstall.go
index 5a8250a054..b6b5716a3d 100644
--- a/config/verifyInstall.go
+++ b/config/verifyInstall.go
@@ -52,7 +52,7 @@ func VerifyFFMpegPath(path string) error {
versionString := "v" + strings.Split(fullVersionString, "-")[0]
- // Some builds of ffmpeg have wierd build numbers that we can't parse
+ // Some builds of ffmpeg have weird build numbers that we can't parse
if !semver.IsValid(versionString) {
log.Debugf("unable to determine if ffmpeg version %s is recent enough. if you experience issues with video you may want to look into updating", fullVersionString)
return nil
diff --git a/controllers/admin/config.go b/controllers/admin/config.go
index 734181f3fc..e926e0ad5f 100644
--- a/controllers/admin/config.go
+++ b/controllers/admin/config.go
@@ -35,7 +35,7 @@ func SetTags(w http.ResponseWriter, r *http.Request) {
return
}
- var tagStrings []string
+ tagStrings := make([]string, 0)
for _, tag := range configValues {
tagStrings = append(tagStrings, tag.Value.(string))
}
@@ -226,7 +226,7 @@ func SetLogo(w http.ResponseWriter, r *http.Request) {
}
imgPath := filepath.Join("data", "logo"+extension)
- if err := ioutil.WriteFile(imgPath, bytes, 0644); err != nil {
+ if err := ioutil.WriteFile(imgPath, bytes, 0600); err != nil {
controllers.WriteSimpleResponse(w, false, err.Error())
return
}
@@ -434,7 +434,6 @@ func SetS3Configuration(w http.ResponseWriter, r *http.Request) {
if newS3Config.Value.Endpoint == "" || !utils.IsValidUrl((newS3Config.Value.Endpoint)) {
controllers.WriteSimpleResponse(w, false, "s3 support requires an endpoint")
return
-
}
if newS3Config.Value.AccessKey == "" || newS3Config.Value.Secret == "" {
@@ -455,7 +454,6 @@ func SetS3Configuration(w http.ResponseWriter, r *http.Request) {
data.SetS3Config(newS3Config.Value)
controllers.WriteSimpleResponse(w, true, "storage configuration changed")
-
}
// SetStreamOutputVariants will handle the web config request to set the video output stream variants.
diff --git a/controllers/video.go b/controllers/video.go
index 6cdca3a913..80c9bed459 100644
--- a/controllers/video.go
+++ b/controllers/video.go
@@ -15,7 +15,7 @@ type variantsResponse struct {
Index int `json:"index"`
}
-// GetVideoStreamOutputVariants will return the video variants available,
+// GetVideoStreamOutputVariants will return the video variants available.
func GetVideoStreamOutputVariants(w http.ResponseWriter, r *http.Request) {
outputVariants := data.GetStreamOutputVariants()
result := make([]variantsResponse, len(outputVariants))
diff --git a/core/data/config.go b/core/data/config.go
index d46f5d5b00..12f5384877 100644
--- a/core/data/config.go
+++ b/core/data/config.go
@@ -199,7 +199,7 @@ func GetHTTPListenAddress() string {
log.Traceln(httpListenAddressKey, err)
return config.GetDefaults().WebServerIP
}
- return string(address)
+ return address
}
// SetHTTPListenAddress will set the server HTTP listen address.
@@ -577,7 +577,7 @@ func FindHighestVideoQualityIndex(qualities []models.StreamOutputVariant) int {
return indexedQualities[0].index
}
-// GetUsernameBlocklist will return the blocked usernames as a comma seperated string.
+// GetUsernameBlocklist will return the blocked usernames as a comma separated string.
func GetUsernameBlocklist() string {
usernameString, err := _datastore.GetString(blockedUsernamesKey)
@@ -589,7 +589,7 @@ func GetUsernameBlocklist() string {
return usernameString
}
-// SetUsernameBlocklist set the username blocklist as a comma seperated string.
+// SetUsernameBlocklist set the username blocklist as a comma separated string.
func SetUsernameBlocklist(usernames string) error {
return _datastore.SetString(blockedUsernamesKey, usernames)
}
diff --git a/core/streamState.go b/core/streamState.go
index b796c21e72..7f409ff7a0 100644
--- a/core/streamState.go
+++ b/core/streamState.go
@@ -113,7 +113,7 @@ func SetStreamAsDisconnected() {
}
variantPlaylist := playlist.(*m3u8.MediaPlaylist)
- if len(variantPlaylist.Segments) > int(data.GetStreamLatencyLevel().SegmentCount) {
+ if len(variantPlaylist.Segments) > data.GetStreamLatencyLevel().SegmentCount {
variantPlaylist.Segments = variantPlaylist.Segments[:len(variantPlaylist.Segments)]
}
diff --git a/core/transcoder/hlsFilesystemCleanup.go b/core/transcoder/hlsFilesystemCleanup.go
index a13a43cff1..93bfdbbffa 100644
--- a/core/transcoder/hlsFilesystemCleanup.go
+++ b/core/transcoder/hlsFilesystemCleanup.go
@@ -14,7 +14,7 @@ import (
// in the stream.
func CleanupOldContent(baseDirectory string) {
// Determine how many files we should keep on disk
- maxNumber := int(data.GetStreamLatencyLevel().SegmentCount)
+ maxNumber := data.GetStreamLatencyLevel().SegmentCount
buffer := 10
files, err := getAllFilesRecursive(baseDirectory)
diff --git a/logging/logging.go b/logging/logging.go
index 246b4060bb..a49db0b8bd 100644
--- a/logging/logging.go
+++ b/logging/logging.go
@@ -25,13 +25,14 @@ type OCLogger struct {
}
var Logger *OCLogger
-var _level logrus.Level
// Setup configures our custom logging destinations.
func Setup(enableDebugOptions bool, enableVerboseLogging bool) {
// Create the logging directory if needed
if !utils.DoesFileExists(getLogFilePath()) {
- os.Mkdir(getLogFilePath(), 0700)
+ if err := os.Mkdir(getLogFilePath(), 0700); err != nil {
+ logger.Errorln("unable to create directory", getLogFilePath(), err)
+ }
}
// Write logs to a file
diff --git a/main.go b/main.go
index b936353e75..777b6980e0 100644
--- a/main.go
+++ b/main.go
@@ -18,7 +18,6 @@ import (
)
func main() {
-
// Enable bundling of admin assets
_ = pkger.Include("/admin")
@@ -48,7 +47,9 @@ func main() {
// Create the data directory if needed
if !utils.DoesFileExists("data") {
- os.Mkdir("./data", 0700)
+ if err := os.Mkdir("./data", 0700); err != nil {
+ log.Fatalln("Cannot create data directory", err)
+ }
}
// Allows a user to restore a specific database backup
diff --git a/utils/backup.go b/utils/backup.go
index 19edde1ae1..e485fca9e4 100644
--- a/utils/backup.go
+++ b/utils/backup.go
@@ -22,18 +22,18 @@ func Restore(backupFile string, databaseFile string) error {
data, err := ioutil.ReadFile(backupFile)
if err != nil {
- return errors.New(fmt.Sprintf("Unable to read backup file %s", err))
+ return fmt.Errorf("Unable to read backup file %s", err)
}
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
- return errors.New(fmt.Sprintf("Unable to read backup file %s", err))
+ return fmt.Errorf("Unable to read backup file %s", err)
}
defer gz.Close()
var b bytes.Buffer
if _, err := io.Copy(&b, gz); err != nil {
- return errors.New(fmt.Sprintf("Unable to read backup file %s", err))
+ return fmt.Errorf("Unable to read backup file %s", err)
}
defer gz.Close()