1# Status
2
3This is a convenience package for users of `gogo/protobuf` to be able to use
4their `gogo/protobuf` generated message easily and transparently with the
5gRPC status error structure.
6
7It requires [Go gRPC version 1.11](https://github.com/grpc/grpc-go/releases/tag/v1.11.0)
8or above to successfully transmit statuses over the gRPC transport.
9
10## Use
11
12Use as you would the normal `grpc/status` package:
13
14```go
15return status.Error(codes.NotFound, "no such user")
16```
17
18```go
19st := status.New(codes.FailedPrecondition, "wrong user role")
20detSt, err := st.WithDetails(&rpc.BadRequest{
21    FieldViolations: []*rpc.BadRequest_FieldViolation{
22        {
23            Field:       "role",
24            Description: "The first user created must have the role of an ADMIN",
25        },
26    },
27})
28if err == nil {
29    return detSt.Err()
30}
31return st.Err()
32```
33
34## License
35
36The code is 95% copied from the official gRPC status package, so the gRPC
37License applies.
38
39### Changes
40
41The changes applied include changing the use of the
42`golang/protobuf` packages to `gogo/protobuf`, and changing the
43generated files from `google.golang.org/genproto/googleapis` to
44`github.com/gogo/googleapis/`.
45
46We've also created an implicit interface fulfilled by all `gogo/status`
47errors, for use with `grpc/status` and the gRPC runtime libraries.
48