add some go-critic suggestions
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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{})
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user