small cleanup:

- be explicit when discarding returned errors from .Close(), etc.
- remove named return values from funcs when naked return not used
- fix some "err" shadowing when redeclaration not needed
This commit is contained in:
George Armhold 2017-10-25 12:03:55 -04:00
parent 8d37b723ca
commit bcdebfb84e
8 changed files with 12 additions and 11 deletions

View file

@ -218,7 +218,7 @@ func (be *b2Backend) Load(ctx context.Context, h restic.Handle, length int, offs
}
// Save stores data in the backend at the handle.
func (be *b2Backend) Save(ctx context.Context, h restic.Handle, rd io.Reader) (err error) {
func (be *b2Backend) Save(ctx context.Context, h restic.Handle, rd io.Reader) (error) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@ -233,7 +233,7 @@ func (be *b2Backend) Save(ctx context.Context, h restic.Handle, rd io.Reader) (e
debug.Log("Save %v, name %v", h, name)
obj := be.bucket.Object(name)
_, err = obj.Attrs(ctx)
_, err := obj.Attrs(ctx)
if err == nil {
debug.Log(" %v already exists", h)
return errors.New("key already exists")

View file

@ -118,7 +118,7 @@ func (b *Local) IsNotExist(err error) bool {
}
// Save stores data in the backend at the handle.
func (b *Local) Save(ctx context.Context, h restic.Handle, rd io.Reader) (err error) {
func (b *Local) Save(ctx context.Context, h restic.Handle, rd io.Reader) (error) {
debug.Log("Save %v", h)
if err := h.Valid(); err != nil {
return err