chore: refactor error comparison (#3629)

master
Kevin Wan 1 year ago committed by GitHub
parent fd070fec91
commit d71c0da7b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,6 +3,7 @@ package sqlx
import ( import (
"context" "context"
"database/sql" "database/sql"
"errors"
"github.com/zeromicro/go-zero/core/trace" "github.com/zeromicro/go-zero/core/trace"
"go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/attribute"
@ -23,7 +24,7 @@ func startSpan(ctx context.Context, method string) (context.Context, oteltrace.S
func endSpan(span oteltrace.Span, err error) { func endSpan(span oteltrace.Span, err error) {
defer span.End() defer span.End()
if err == nil || err == sql.ErrNoRows { if err == nil || errors.Is(err, sql.ErrNoRows) {
span.SetStatus(codes.Ok, "") span.SetStatus(codes.Ok, "")
return return
} }

Loading…
Cancel
Save