feat(ci): add a bunch more linters

This commit is contained in:
sentriz
2023-09-22 19:05:20 +02:00
parent 33f1f2e0cf
commit e3dd812b6c
37 changed files with 233 additions and 139 deletions

View File

@@ -9,7 +9,7 @@ import (
"path/filepath"
)
const perm = 0644
const perm = 0o644
type CachingTranscoder struct {
cachePath string
@@ -23,7 +23,7 @@ func NewCachingTranscoder(t Transcoder, cachePath string) *CachingTranscoder {
}
func (t *CachingTranscoder) Transcode(ctx context.Context, profile Profile, in string, out io.Writer) error {
if err := os.MkdirAll(t.cachePath, perm^0111); err != nil {
if err := os.MkdirAll(t.cachePath, perm^0o111); err != nil {
return fmt.Errorf("make cache path: %w", err)
}
@@ -35,7 +35,7 @@ func (t *CachingTranscoder) Transcode(ctx context.Context, profile Profile, in s
key := cacheKey(name, args)
path := filepath.Join(t.cachePath, key)
cf, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644)
cf, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0o644)
if err != nil {
return fmt.Errorf("open cache file: %w", err)
}

View File

@@ -16,8 +16,10 @@ func NewFFmpegTranscoder() *FFmpegTranscoder {
return &FFmpegTranscoder{}
}
var ErrFFmpegKilled = fmt.Errorf("ffmpeg was killed early")
var ErrFFmpegExit = fmt.Errorf("ffmpeg exited with non 0 status code")
var (
ErrFFmpegKilled = fmt.Errorf("ffmpeg was killed early")
ErrFFmpegExit = fmt.Errorf("ffmpeg exited with non 0 status code")
)
func (*FFmpegTranscoder) Transcode(ctx context.Context, profile Profile, in string, out io.Writer) error {
name, args, err := parseProfile(profile, in)
@@ -36,7 +38,7 @@ func (*FFmpegTranscoder) Transcode(ctx context.Context, profile Profile, in stri
switch err := cmd.Wait(); {
case errors.As(err, &exitErr):
return fmt.Errorf("waiting cmd: %v: %w", err, ErrFFmpegKilled)
return fmt.Errorf("waiting cmd: %w: %w", err, ErrFFmpegKilled)
case err != nil:
return fmt.Errorf("waiting cmd: %w", err)
}