Correct Error Handling is Hard
Peter Goetz

You can probably make this a little nicer with return parameters:

func WriteBucketObject(src io.Reader) (err error) {
writer := gcpClient.Bucket("my-gcp-bucket").Object("my-object").NewWriter(context.TODO())
    defer func () {
closeErr = writer.Close()
if err != nil {
            // Optionally wrap the existing error
// in the close error
err = errors.Wrap(err, closeErr.Error())
        err = closeErr
    _, e := io.Copy(writer, src)
if e != nil {
return errors.Wrapf(e, "Path %v", path)

return nil
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.