diff --git a/cmd/gonicembed/main.go b/cmd/gonicembed/main.go index 1c03703..440371b 100644 --- a/cmd/gonicembed/main.go +++ b/cmd/gonicembed/main.go @@ -75,7 +75,7 @@ type config struct { assetPathPrefix string } -func processAsset(c config, ew *errWriter, path string) error { +func processAsset(c *config, ew *errWriter, path string) error { info, err := os.Stat(path) if err != nil { return fmt.Errorf("stating asset: %w", err) @@ -107,8 +107,7 @@ func processAsset(c config, ew *errWriter, path string) error { return ew.err } -//nolint:errcheck -func processAssets(c config, files []string) error { +func processAssets(c *config, files []string) error { out, err := os.Create(c.outPath) if err != nil { return fmt.Errorf("creating out path: %w", err) @@ -144,7 +143,7 @@ func main() { if *outPath == "" { log.Fatalln("invalid arguments. see -h") } - c := config{ + c := &config{ packageName: *pkgName, outPath: *outPath, tagList: *tagList, diff --git a/server/ctrladmin/ctrl.go b/server/ctrladmin/ctrl.go index f5557ce..7e0b694 100644 --- a/server/ctrladmin/ctrl.go +++ b/server/ctrladmin/ctrl.go @@ -236,7 +236,8 @@ type Flash struct { Type FlashType } -//nolint:gochecknoinits +//nolint:gochecknoinits // for now I think it's nice that our types and their +// gob registrations are next to each other, in case there's more added later) func init() { gob.Register(&Flash{}) } diff --git a/server/ctrladmin/handlers_playlist.go b/server/ctrladmin/handlers_playlist.go index 6d3c53b..88d0c5f 100644 --- a/server/ctrladmin/handlers_playlist.go +++ b/server/ctrladmin/handlers_playlist.go @@ -82,7 +82,7 @@ func (c *Controller) ServeUploadPlaylist(r *http.Request) *Response { } func (c *Controller) ServeUploadPlaylistDo(r *http.Request) *Response { - if err := r.ParseMultipartForm((1 << 10) * 24); nil != err { + if err := r.ParseMultipartForm((1 << 10) * 24); err != nil { return &Response{ err: "couldn't parse mutlipart", code: 500, diff --git a/server/ctrlsubsonic/ctrl_test.go b/server/ctrlsubsonic/ctrl_test.go index 4748c0c..ed0189d 100644 --- a/server/ctrlsubsonic/ctrl_test.go +++ b/server/ctrlsubsonic/ctrl_test.go @@ -53,7 +53,7 @@ func runQueryCases(t *testing.T, h handlerSubsonic, cases []*queryCase) { // convert test name to query case path snake := testCamelExpr.ReplaceAllString(t.Name(), "${1}_${2}") lower := strings.ToLower(snake) - relPath := strings.Replace(lower, "/", "_", -1) + relPath := strings.ReplaceAll(lower, "/", "_") absExpPath := path.Join(testDataDir, relPath) // read case to differ with handler result expected, err := jd.ReadJsonFile(absExpPath) diff --git a/server/db/model.go b/server/db/model.go index 16db3fe..adb8b32 100644 --- a/server/db/model.go +++ b/server/db/model.go @@ -1,5 +1,5 @@ // Package db provides database helpers and models -//nolint:lll +//nolint:lll // struct tags get very long and can't be split package db // see this db fiddle to mess around with the schema @@ -15,7 +15,7 @@ import ( ) func splitInt(in, sep string) []int { - if len(in) == 0 { + if in == "" { return []int{} } parts := strings.Split(in, sep) diff --git a/server/encode/encode.go b/server/encode/encode.go index 6c1023d..8dbca82 100644 --- a/server/encode/encode.go +++ b/server/encode/encode.go @@ -14,7 +14,8 @@ import ( ) const ( - buffLen = 4096 + buffLen = 4096 + ffmpegPath = "/usr/bin/ffmpeg" ) type Profile struct { @@ -34,7 +35,7 @@ func Profiles() map[string]Profile { } // copy command output to http response body using io.copy (simpler, but may increase ttfb) -//nolint:deadcode,unused +//nolint:deadcode,unused // function may be switched later func copyCmdOutput(out, cache io.Writer, pipeReader io.Reader) { // set up a multiwriter to feed the command output // to both cache file and http response @@ -46,7 +47,7 @@ func copyCmdOutput(out, cache io.Writer, pipeReader io.Reader) { } // copy command output to http response manually with a buffer (should reduce ttfb) -//nolint:deadcode,unused +//nolint:deadcode,unused // function may be switched later func writeCmdOutput(out, cache io.Writer, pipeReader io.ReadCloser) { buffer := make([]byte, buffLen) for { @@ -94,7 +95,8 @@ func ffmpegCommand(filePath string, profile Profile, bitrate string) *exec.Cmd { ) } args = append(args, "-f", profile.Format, "-") - return exec.Command("/usr/bin/ffmpeg", args...) //nolint:gosec + return exec.Command(ffmpegPath, args...) //nolint:gosec // can't see a way for this be abused + // but please do let me know if you see otherwise } func Encode(out io.Writer, trackPath, cachePath string, profile Profile, bitrate string) error { diff --git a/server/jukebox/jukebox.go b/server/jukebox/jukebox.go index be9a959..dbce097 100644 --- a/server/jukebox/jukebox.go +++ b/server/jukebox/jukebox.go @@ -180,15 +180,13 @@ func (j *Jukebox) doUpdateSpeaker(su updateSpeaker) error { return err } j.Lock() - { - j.info = &strmInfo{} - j.info.strm = streamer.(beep.StreamSeekCloser) - j.info.ctrlStrmr.Streamer = beep.Resample( - 4, format.SampleRate, - j.sr, j.info.strm, - ) - j.info.format = format - } + j.info = &strmInfo{} + j.info.strm = streamer.(beep.StreamSeekCloser) + j.info.ctrlStrmr.Streamer = beep.Resample( + 4, format.SampleRate, + j.sr, j.info.strm, + ) + j.info.format = format j.Unlock() speaker.Play(beep.Seq(&j.info.ctrlStrmr, beep.Callback(func() { j.speaker <- updateSpeaker{su.index + 1}