Golint cleanup pkg/storage

This commit is contained in:
Harshavardhana
2015-03-05 20:32:04 -08:00
parent 256faddab5
commit 76e601b26b
7 changed files with 89 additions and 72 deletions

View File

@@ -1,5 +1,5 @@
/*
* Mini Object Storage, (C) 2015 Minio, Inc.
* Minio Object Storage, (C) 2015 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -72,9 +72,8 @@ func (storage *storage) CopyObjectToWriter(w io.Writer, bucket string, object st
objectBuffer := bytes.NewBuffer(val.data)
written, err := io.Copy(w, objectBuffer)
return written, err
} else {
return 0, mstorage.ObjectNotFound{Bucket: bucket, Object: object}
}
return 0, mstorage.ObjectNotFound{Bucket: bucket, Object: object}
}
// Not implemented
@@ -176,16 +175,16 @@ func (storage *storage) ListObjects(bucket string, resources mstorage.BucketReso
return results, resources, nil
}
type ByBucketName []mstorage.BucketMetadata
type byBucketName []mstorage.BucketMetadata
// Len of bucket name
func (b ByBucketName) Len() int { return len(b) }
func (b byBucketName) Len() int { return len(b) }
// Swap bucket i, j
func (b ByBucketName) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
func (b byBucketName) Swap(i, j int) { b[i], b[j] = b[j], b[i] }
// Less
func (b ByBucketName) Less(i, j int) bool { return b[i].Name < b[j].Name }
func (b byBucketName) Less(i, j int) bool { return b[i].Name < b[j].Name }
// List buckets
func (storage *storage) ListBuckets() ([]mstorage.BucketMetadata, error) {
@@ -193,7 +192,7 @@ func (storage *storage) ListBuckets() ([]mstorage.BucketMetadata, error) {
for _, bucket := range storage.bucketdata {
results = append(results, bucket.metadata)
}
sort.Sort(ByBucketName(results))
sort.Sort(byBucketName(results))
return results, nil
}
@@ -203,7 +202,6 @@ func (storage *storage) GetObjectMetadata(bucket, key string) (mstorage.ObjectMe
if object, ok := storage.objectdata[objectKey]; ok == true {
return object.metadata, nil
} else {
return mstorage.ObjectMetadata{}, mstorage.ObjectNotFound{Bucket: bucket, Object: key}
}
return mstorage.ObjectMetadata{}, mstorage.ObjectNotFound{Bucket: bucket, Object: key}
}