Address golint recommendations.

This commit is contained in:
Randall McPherson 2014-06-23 17:40:29 -04:00
Родитель a67cbd2bf8
Коммит c8635b85d6
8 изменённых файлов: 21 добавлений и 25 удалений

Просмотреть файл

@ -27,7 +27,7 @@ type mdCreds struct {
Expiration string
}
// Requests the AWS keys from the instance-based metadata on EC2
// InstanceKeys Requests the AWS keys from the instance-based metadata on EC2
// Assumes only one IAM role.
func InstanceKeys() (keys Keys, err error) {
@ -77,13 +77,13 @@ func InstanceKeys() (keys Keys, err error) {
return
}
// Reads the AWS keys from the environment
// EnvKeys Reads the AWS keys from the environment
func EnvKeys() (keys Keys, err error) {
keys = Keys{AccessKey: os.Getenv("AWS_ACCESS_KEY_ID"),
SecretKey: os.Getenv("AWS_SECRET_ACCESS_KEY"),
}
if keys.AccessKey == "" || keys.SecretKey == "" {
err = fmt.Errorf("Keys not set in environment: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY")
err = fmt.Errorf("keys not set in environment: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY")
}
return
}

Просмотреть файл

@ -55,7 +55,7 @@ func TestEnvKeysNotSet(t *testing.T) {
s := authT{}
s.saveEnv()
_, err := EnvKeys()
expErr := "Keys not set in environment: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY"
expErr := "keys not set in environment: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY"
if err.Error() != expErr {
t.Errorf("Expected error: %v. Actual: %v", expErr, err)
}

Просмотреть файл

@ -26,7 +26,7 @@ type getter struct {
err error
wg sync.WaitGroup
chunkId int
chunkID int
rChunk *chunk
contentLen int64
bytesRead int64
@ -54,9 +54,9 @@ type chunk struct {
len int64
}
func newGetter(p_url url.URL, c *Config, b *Bucket) (io.ReadCloser, http.Header, error) {
func newGetter(getURL url.URL, c *Config, b *Bucket) (io.ReadCloser, http.Header, error) {
g := new(getter)
g.url = p_url
g.url = getURL
g.c = c
g.bufsz = max64(c.PartSize, 1)
g.c.NTry = max(c.NTry, 1)
@ -70,7 +70,7 @@ func newGetter(p_url url.URL, c *Config, b *Bucket) (io.ReadCloser, http.Header,
g.md5 = md5.New()
// use get instead of head for error messaging
resp, err := g.retryRequest("GET", p_url.String(), nil)
resp, err := g.retryRequest("GET", g.url.String(), nil)
if err != nil {
return nil, nil, err
}
@ -220,7 +220,7 @@ func (g *getter) Read(p []byte) (int, error) {
}
g.bp.give <- g.rChunk.b // recycle buffer
g.rChunk = nil
g.chunkId++
g.chunkID++
}
g.bytesRead = g.bytesRead + int64(n)
return n, err
@ -230,9 +230,9 @@ func (g *getter) nextChunk() (*chunk, error) {
for {
// first check qWait
c := g.qWait[g.chunkId]
c := g.qWait[g.chunkID]
if c != nil {
delete(g.qWait, g.chunkId)
delete(g.qWait, g.chunkID)
return c, nil
}
// if next chunk not in qWait, read from channel

10
pool.go
Просмотреть файл

@ -6,7 +6,7 @@ import (
"time"
)
type q_buf struct {
type qBuf struct {
when time.Time
buffer *bytes.Buffer
}
@ -32,7 +32,7 @@ func newBufferPool(bufsz int64) (np *bp) {
for {
if q.Len() == 0 {
size := bufsz + 100*kb // allocate overhead to avoid slice growth
q.PushFront(q_buf{when: time.Now(), buffer: bytes.NewBuffer(makeBuffer(int64(size)))})
q.PushFront(qBuf{when: time.Now(), buffer: bytes.NewBuffer(makeBuffer(int64(size)))})
np.makes++
}
@ -42,9 +42,9 @@ func newBufferPool(bufsz int64) (np *bp) {
select {
case b := <-np.give:
timeout.Stop()
q.PushFront(q_buf{when: time.Now(), buffer: b})
q.PushFront(qBuf{when: time.Now(), buffer: b})
case np.get <- e.Value.(q_buf).buffer:
case np.get <- e.Value.(qBuf).buffer:
timeout.Stop()
q.Remove(e)
@ -53,7 +53,7 @@ func newBufferPool(bufsz int64) (np *bp) {
e := q.Front()
for e != nil {
n := e.Next()
if time.Since(e.Value.(q_buf).when) > time.Minute {
if time.Since(e.Value.(qBuf).when) > time.Minute {
q.Remove(e)
e.Value = nil
}

Просмотреть файл

@ -59,17 +59,13 @@ type putter struct {
bp *bp
makes int
UploadId string
UploadId string // casing matches s3 xml
xml struct {
XMLName string `xml:"CompleteMultipartUpload"`
Part []*part
}
}
type completeXml struct {
ETag string
}
// Sends an S3 multipart upload initiation request.
// See http://docs.amazonwebservices.com/AmazonS3/latest/dev/mpuoverview.html.
// The initial request returns an UploadId that we use to identify

Просмотреть файл

@ -95,11 +95,11 @@ func (b *Bucket) PutWriter(path string, h http.Header, c *Config) (w io.WriteClo
// Url returns a parsed url to the given path, using the scheme specified in Config.Scheme
func (b *Bucket) Url(path string, c *Config) url.URL {
url_, err := url.Parse(fmt.Sprintf("%s://%s.%s/%s", c.Scheme, b.Name, b.S3.Domain, path))
bURL, err := url.Parse(fmt.Sprintf("%s://%s.%s/%s", c.Scheme, b.Name, b.S3.Domain, path))
if err != nil {
panic(err)
}
return *url_
return *bURL
}
// SetLogger wraps the standard library log package.

Просмотреть файл

@ -181,7 +181,7 @@ func testBucket() (*tB, error) {
}
bucket := os.Getenv("TEST_BUCKET")
if bucket == "" {
return nil, errors.New("TEST_BUCKET must be set in environment.")
return nil, errors.New("TEST_BUCKET must be set in environment")
}
s3 := New("", k)

Просмотреть файл

@ -80,7 +80,7 @@ func (b *Bucket) writeSignature(w io.Writer, r *http.Request) {
func (b *Bucket) writeCanonicalizedAmzHeaders(w io.Writer, r *http.Request) {
var amzHeaders []string
for h, _ := range r.Header {
for h := range r.Header {
if strings.HasPrefix(strings.ToLower(h), "x-amz-") {
amzHeaders = append(amzHeaders, h)
}