Skip to content

Commit

Permalink
gofumpt everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Mjaethers committed Jan 14, 2024
1 parent 3251366 commit bc9c8c1
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 26 deletions.
6 changes: 4 additions & 2 deletions api/live_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ const (
UpdateTypeCourseWentLive = "course_went_live"
)

var liveUpdateListenerMutex sync.RWMutex
var liveUpdateListener = map[uint]*liveUpdateUserSessionsWrapper{}
var (
liveUpdateListenerMutex sync.RWMutex
liveUpdateListener = map[uint]*liveUpdateUserSessionsWrapper{}
)

type liveUpdateUserSessionsWrapper struct {
sessions []*realtime.Context
Expand Down
9 changes: 5 additions & 4 deletions api/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ import (
"encoding/json"
"errors"
"fmt"
"net/http"
"regexp"
"strings"
"time"

"github.com/TUM-Dev/gocast/dao"
"github.com/TUM-Dev/gocast/model"
"github.com/TUM-Dev/gocast/tools"
"github.com/getsentry/sentry-go"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
"net/http"
"regexp"
"strings"
"time"
)

func configGinUsersRouter(router *gin.Engine, daoWrapper dao.DaoWrapper) {
Expand Down
2 changes: 1 addition & 1 deletion api/worker_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ func getLivePreviewFromWorker(s *model.Stream, workerID string, client pb.ToWork
return err
}

if err := os.MkdirAll(pathprovider.TUMLiveTemporary, 0750); err != nil {
if err := os.MkdirAll(pathprovider.TUMLiveTemporary, 0o750); err != nil {
return err
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/modelGen/modelGen.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
}

fmt.Println("Generating model...")
model_file, err := os.OpenFile(fmt.Sprintf("model/%s.go", d.NamePrivate), os.O_WRONLY|os.O_CREATE, 0644)
model_file, err := os.OpenFile(fmt.Sprintf("model/%s.go", d.NamePrivate), os.O_WRONLY|os.O_CREATE, 0o644)
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand All @@ -46,7 +46,7 @@ func main() {

fmt.Println("Generating dao...")

dao_file, err := os.OpenFile(fmt.Sprintf("dao/%s.go", d.NamePrivate), os.O_WRONLY|os.O_CREATE, 0644)
dao_file, err := os.OpenFile(fmt.Sprintf("dao/%s.go", d.NamePrivate), os.O_WRONLY|os.O_CREATE, 0o644)
if err != nil {
fmt.Println(err)
os.Exit(1)
Expand Down
6 changes: 4 additions & 2 deletions tools/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ import (
"github.com/spf13/viper"
)

var Cfg Config
var Loc *time.Location
var (
Cfg Config
Loc *time.Location
)

func LoadConfig() {
initCache()
Expand Down
11 changes: 6 additions & 5 deletions web/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ package web

import (
"errors"
"html/template"
"math"
"net/http"
"strconv"
"strings"

"github.com/TUM-Dev/gocast/api"
"github.com/TUM-Dev/gocast/dao"
"github.com/TUM-Dev/gocast/model"
Expand All @@ -10,11 +16,6 @@ import (
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"gorm.io/gorm"
"html/template"
"math"
"net/http"
"strconv"
"strings"
)

func (r mainRoutes) WatchPage(c *gin.Context) {
Expand Down
4 changes: 2 additions & 2 deletions worker/cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ func SetConfig() {
if PersistDir == "" {
PersistDir = "."
}
err := os.MkdirAll(PersistDir, 0755)
err := os.MkdirAll(PersistDir, 0o755)
if err != nil {
log.Error(err)
}
err = os.MkdirAll(LogDir, 0755)
err = os.MkdirAll(LogDir, 0o755)
if err != nil {
log.Warn("Could not create log directory: ", err)
}
Expand Down
2 changes: 1 addition & 1 deletion worker/edge/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func fetchFile(host, file string) error {
return fmt.Errorf("parse file path: %s", file)
}
d := filepath.Dir(diskDir)
err = os.MkdirAll(d, 0755)
err = os.MkdirAll(d, 0o755)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion worker/worker/persist.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const persistFileName = "/persist.gob"

// writeOut writes out the persistable object to disk
func (p *Persistable) writeOut() error {
f, err := os.OpenFile(cfg.PersistDir+persistFileName, os.O_RDWR|os.O_CREATE, 0666)
f, err := os.OpenFile(cfg.PersistDir+persistFileName, os.O_RDWR|os.O_CREATE, 0o666)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion worker/worker/premiere.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func streamPremiere(ctx *StreamContext) {
"-acodec", "aac", "-b:a", "128k", "-ac", "2", "-ar", "48000", "-af", "aresample=async=1:min_hard_comp=0.100000:first_pts=0",
"-f", "flv", fmt.Sprintf("%s%s", ctx.ingestServer, ctx.streamName))
log.WithField("cmd", cmd.String()).Info("Starting premiere")
ffmpegErr, errFfmpegErrFile := os.OpenFile(fmt.Sprintf("%s/ffmpeg_%s.log", cfg.LogDir, ctx.getStreamName()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
ffmpegErr, errFfmpegErrFile := os.OpenFile(fmt.Sprintf("%s/ffmpeg_%s.log", cfg.LogDir, ctx.getStreamName()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0o644)
if errFfmpegErrFile == nil {
cmd.Stderr = ffmpegErr
} else {
Expand Down
2 changes: 1 addition & 1 deletion worker/worker/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func stream(streamCtx *StreamContext) {
// persist stream command in context, so it can be killed later
streamCtx.streamCmd = cmd
log.WithField("cmd", cmd.String()).Info("Starting stream")
ffmpegErr, errFfmpegErrFile := os.OpenFile(fmt.Sprintf("%s/ffmpeg_%s.log", cfg.LogDir, streamCtx.getStreamName()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644)
ffmpegErr, errFfmpegErrFile := os.OpenFile(fmt.Sprintf("%s/ffmpeg_%s.log", cfg.LogDir, streamCtx.getStreamName()), os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0o644)
if errFfmpegErrFile == nil {
cmd.Stderr = ffmpegErr
} else {
Expand Down
2 changes: 1 addition & 1 deletion worker/worker/thumbnails.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func createVideoThumbnail(ctx *StreamContext, source string) error {
if err != nil {
return err
}
file, err := os.OpenFile(ctx.getLargeThumbnailSpriteFileName(), os.O_CREATE|os.O_WRONLY, 0644)
file, err := os.OpenFile(ctx.getLargeThumbnailSpriteFileName(), os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions worker/worker/transcode.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func handleTranscodingOutput(stderr io.ReadCloser, inputTime float64, progressCh
// creates folder for output file if it doesn't exist
func prepare(out string) error {
dir := filepath.Dir(out)
err := os.MkdirAll(dir, 0750)
err := os.MkdirAll(dir, 0o750)
if err != nil {
return fmt.Errorf("create output directory for transcoding: %s", err)
}
Expand All @@ -159,7 +159,7 @@ func prepare(out string) error {
// markForDeletion moves the file to $recfolder/.trash/
func markForDeletion(ctx *StreamContext) error {
trashName := ctx.getRecordingTrashName()
err := os.MkdirAll(filepath.Dir(trashName), 0750)
err := os.MkdirAll(filepath.Dir(trashName), 0o750)
if err != nil {
return fmt.Errorf("create trash directory: %s", err)
}
Expand Down
2 changes: 1 addition & 1 deletion worker/worker/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func createDummyFile(filesize uint) (string, error) {
if err != nil {
return "", err
}
f, err := os.OpenFile(file.Name(), os.O_APPEND|os.O_WRONLY, 0600)
f, err := os.OpenFile(file.Name(), os.O_APPEND|os.O_WRONLY, 0o600)
if err != nil {
return "", err
}
Expand Down

0 comments on commit bc9c8c1

Please sign in to comment.