From 56a298fd6a5db9c761bf764971f80410b1b83e9e Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Mon, 23 Mar 2015 12:25:15 -0700 Subject: [PATCH 1/2] Refactoring method variable names for erasureWriter struct --- pkg/storage/donut/erasure.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pkg/storage/donut/erasure.go b/pkg/storage/donut/erasure.go index 4c85eafc5..ff42a15b5 100644 --- a/pkg/storage/donut/erasure.go +++ b/pkg/storage/donut/erasure.go @@ -121,19 +121,19 @@ func erasureGoroutine(r *io.PipeReader, eWriter erasureWriter, isClosed chan<- b isClosed <- true } -func (d erasureWriter) Write(data []byte) (int, error) { - io.Copy(d.erasureWriter, bytes.NewBuffer(data)) +func (eWriter erasureWriter) Write(data []byte) (int, error) { + io.Copy(eWriter.erasureWriter, bytes.NewBuffer(data)) return len(data), nil } -func (d erasureWriter) Close() error { - d.erasureWriter.Close() - <-d.isClosed +func (eWriter erasureWriter) Close() error { + eWriter.erasureWriter.Close() + <-eWriter.isClosed return nil } -func (d erasureWriter) CloseWithError(err error) error { - for _, writer := range d.writers { +func (eWriter erasureWriter) CloseWithError(err error) error { + for _, writer := range eWriter.writers { if writer != nil { writer.CloseWithError(err) } @@ -141,24 +141,24 @@ func (d erasureWriter) CloseWithError(err error) error { return nil } -func (d erasureWriter) SetMetadata(metadata map[string]string) error { +func (eWriter erasureWriter) SetMetadata(metadata map[string]string) error { for k, _ := range metadata { if strings.HasPrefix(k, "sys.") { return errors.New("Invalid key '" + k + "', cannot start with sys.'") } } - for k := range d.metadata { - delete(d.metadata, k) + for k := range eWriter.metadata { + delete(eWriter.metadata, k) } for k, v := range metadata { - d.metadata[k] = v + eWriter.metadata[k] = v } return nil } -func (d erasureWriter) GetMetadata() (map[string]string, error) { +func (eWriter erasureWriter) GetMetadata() (map[string]string, error) { metadata := make(map[string]string) - for k, v := range d.metadata { + for k, v := range eWriter.metadata { metadata[k] = v } return metadata, nil From f91f5e59eeb7e6d658a580b82394dcd5b62f9dec Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Mon, 23 Mar 2015 12:26:41 -0700 Subject: [PATCH 2/2] Running gofmt manually, auto gofmt didn't simplify code --- pkg/storage/donut/erasure.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/storage/donut/erasure.go b/pkg/storage/donut/erasure.go index ff42a15b5..3574b1906 100644 --- a/pkg/storage/donut/erasure.go +++ b/pkg/storage/donut/erasure.go @@ -142,7 +142,7 @@ func (eWriter erasureWriter) CloseWithError(err error) error { } func (eWriter erasureWriter) SetMetadata(metadata map[string]string) error { - for k, _ := range metadata { + for k := range metadata { if strings.HasPrefix(k, "sys.") { return errors.New("Invalid key '" + k + "', cannot start with sys.'") }