Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code bug: should return a error but return a nil value error #2762

Closed
alingse opened this issue Dec 15, 2024 · 2 comments · Fixed by #2763
Closed

Code bug: should return a error but return a nil value error #2762

alingse opened this issue Dec 15, 2024 · 2 comments · Fixed by #2763

Comments

@alingse
Copy link
Contributor

alingse commented Dec 15, 2024

Environment

  • Server:
  • Client:
  • Protocol:
  • Registry:

Issue description

code 1
https://github.com/apache/dubbo-go/blob/main/config/tls_config.go#L88

	caBytes, err := os.ReadFile(opt.CACertFile)
	if err != nil {
		return nil, err
	}
	if ok := ca.AppendCertsFromPEM(caBytes); !ok {
		return nil, err
	}

the err is nil in line 88, here should define an error to return

code 2

https://github.com/apache/dubbo-go/blob/main/protocol/triple/internal/client/common/client.go#L68

https://github.com/apache/dubbo-go/blob/main/protocol/triple/internal/client/common/client.go#L92

	if sendErr := stream.Send(&greet.GreetStreamRequest{Name: "triple"}); sendErr != nil {
		return err
	}

should return sendErr but return a nil value err

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

Logs

Click me to check logs
Copy logs to here.
@AlexStocks
Copy link
Contributor

Would you please submit a PR to fix it?

@No-SilverBullet
Copy link
Contributor

e that returns a non-relevant nilness error bug. I checked the top 1000 GitHub Go repositories and found this, all result liste

i will submit a PR to fix it

@FoghostCn FoghostCn linked a pull request Dec 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants