Skip to content

should return a error but return a nil value error #616

@alingse

Description

@alingse

Describe the bug

https://github.com/charmbracelet/soft-serve/blob/main/pkg/web/git.go#L472
code in here should return a new err

		nRead, err := r.Read(p)
		if err == io.EOF {
			break
		}
		nWrite, err := f.ResponseWriter.Write(p[:nRead])
		if err != nil {
			return n, err
		}
		if nRead != nWrite {
			return n, err
		}

the err is nil , but here need return a new err

see golang io.Copy implement here
https://github.com/golang/go/blob/master/src/io/io.go#L431-L445

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [e.g. Linux]
  • Terminal [e.g. kitty, iterm2, gnome-terminal]
  • Version [e.g. v0.4.0]

Additional context
Add any other context about the problem here.

I create a linter to detect code that returns a non-relevant nilness error bug. I checked the top 1000 GitHub Go repositories and found this, all result listed in alingse/sundrylint#4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions