Skip to content

Commit

Permalink
Fix another common status allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
dzbarsky committed Jul 23, 2019
1 parent 207b5d8 commit a150f7f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import (
"google.golang.org/grpc/internal"
)

var statusOK = Status{s: &spb.Status{Code: int32(codes.OK)}}

func init() {
internal.StatusRawProto = statusRawProto
}
Expand Down Expand Up @@ -132,7 +134,7 @@ func FromProto(s *spb.Status) *Status {
// Status is returned with codes.Unknown and the original error message.
func FromError(err error) (s *Status, ok bool) {
if err == nil {
return &Status{s: &spb.Status{Code: int32(codes.OK)}}, true
return &statusOK, true
}
if se, ok := err.(interface {
GRPCStatus() *Status
Expand Down

0 comments on commit a150f7f

Please sign in to comment.