Socket
Socket
Sign inDemoInstall

github.com/gogo/status

Package Overview
Dependencies
5
Maintainers
0
Alerts
File Explorer

Install Socket

Protect your apps from supply chain attacks

Install

github.com/gogo/status

Package status implements errors returned by gRPC. These errors are serialized and transmitted on the wire between server and client, and allow for additional data to be transmitted via the Details field in the status proto. gRPC service handlers should return an error created by this package, and gRPC clients should expect a corresponding error to be returned from the RPC call. This package upholds the invariants that a non-nil error may not contain an OK code, and an OK code must result in a nil error.

    v1.1.1

Version published
Maintainers
0

Readme

# Status

This is a convenience package for users of `gogo/protobuf` to be able to use
their `gogo/protobuf` generated message easily and transparently with the
gRPC status error structure.

It requires [Go gRPC version 1.11](https://github.com/grpc/grpc-go/releases/tag/v1.11.0)
or above to successfully transmit statuses over the gRPC transport.

## Use

Use as you would the normal `grpc/status` package:

```go
return status.Error(codes.NotFound, "no such user")
```

```go
st := status.New(codes.FailedPrecondition, "wrong user role")
detSt, err := st.WithDetails(&rpc.BadRequest{
    FieldViolations: []*rpc.BadRequest_FieldViolation{
        {
            Field:       "role",
            Description: "The first user created must have the role of an ADMIN",
        },
    },
})
if err == nil {
    return detSt.Err()
}
return st.Err()
```

## License

The code is 95% copied from the official gRPC status package, so the gRPC
License applies.

### Changes

The changes applied include changing the use of the
`golang/protobuf` packages to `gogo/protobuf`, and changing the
generated files from `google.golang.org/genproto/googleapis` to
`github.com/gogo/googleapis/`.

We've also created an implicit interface fulfilled by all `gogo/status`
errors, for use with `grpc/status` and the gRPC runtime libraries.

FAQs

Last updated on 23 Apr 2022

Did you know?

Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc