Fix example in README

This commit is contained in:
Ilia Choly 2022-05-15 17:15:20 -04:00 committed by GitHub
parent ece2929696
commit 7eb7c7d0dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -122,15 +122,13 @@ func ExampleUsage() {
func(ctx context.Context, id string, dest groupcache.Sink) error {
// Returns a protobuf struct `User`
if user, err := fetchUserFromMongo(ctx, id); err != nil {
user, err := fetchUserFromMongo(ctx, id)
if err != nil {
return err
}
// Set the user in the groupcache to expire after 5 minutes
if err := dest.SetProto(&user, time.Now().Add(time.Minute*5)); err != nil {
return err
}
return nil
return dest.SetProto(&user, time.Now().Add(time.Minute*5))
},
))