Skip to content

Commit 3237a5a

Browse files
run gofumpt -w on codebase
1 parent 37bb066 commit 3237a5a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+214
-191
lines changed

api-bucket-notification.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ func (c *Client) getBucketNotification(ctx context.Context, bucketName string) (
103103
return notification.Configuration{}, err
104104
}
105105
return processBucketNotificationResponse(bucketName, resp)
106-
107106
}
108107

109108
// processes the GetNotification http response from the server.
@@ -207,7 +206,7 @@ func (c *Client) ListenBucketNotification(ctx context.Context, bucketName, prefi
207206
// Use a higher buffer to support unexpected
208207
// caching done by proxies
209208
bio.Buffer(notificationEventBuffer, notificationCapacity)
210-
var json = jsoniter.ConfigCompatibleWithStandardLibrary
209+
json := jsoniter.ConfigCompatibleWithStandardLibrary
211210

212211
// Unmarshal each line, returns marshaled values.
213212
for bio.Scan() {

api-compose-object.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ func (opts CopySrcOptions) validate() (err error) {
202202

203203
// Low level implementation of CopyObject API, supports only upto 5GiB worth of copy.
204204
func (c *Client) copyObjectDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject string,
205-
metadata map[string]string, srcOpts CopySrcOptions, dstOpts PutObjectOptions) (ObjectInfo, error) {
206-
205+
metadata map[string]string, srcOpts CopySrcOptions, dstOpts PutObjectOptions,
206+
) (ObjectInfo, error) {
207207
// Build headers.
208208
headers := make(http.Header)
209209

@@ -285,8 +285,8 @@ func (c *Client) copyObjectDo(ctx context.Context, srcBucket, srcObject, destBuc
285285
}
286286

287287
func (c *Client) copyObjectPartDo(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, uploadID string,
288-
partID int, startOffset int64, length int64, metadata map[string]string) (p CompletePart, err error) {
289-
288+
partID int, startOffset int64, length int64, metadata map[string]string,
289+
) (p CompletePart, err error) {
290290
headers := make(http.Header)
291291

292292
// Set source
@@ -338,8 +338,8 @@ func (c *Client) copyObjectPartDo(ctx context.Context, srcBucket, srcObject, des
338338
// upload via an upload-part-copy request
339339
// https://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPartCopy.html
340340
func (c *Client) uploadPartCopy(ctx context.Context, bucket, object, uploadID string, partNumber int,
341-
headers http.Header) (p CompletePart, err error) {
342-
341+
headers http.Header,
342+
) (p CompletePart, err error) {
343343
// Build query parameters
344344
urlValues := make(url.Values)
345345
urlValues.Set("partNumber", strconv.Itoa(partNumber))
@@ -492,7 +492,7 @@ func (c *Client) ComposeObject(ctx context.Context, dst CopyDestOptions, srcs ..
492492
objParts := []CompletePart{}
493493
partIndex := 1
494494
for i, src := range srcs {
495-
var h = make(http.Header)
495+
h := make(http.Header)
496496
src.Marshal(h)
497497
if dst.Encryption != nil && dst.Encryption.Type() == encrypt.SSEC {
498498
dst.Encryption.Marshal(h)

api-compose-object_test.go

+55-26
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func TestPartsRequired(t *testing.T) {
5555
}
5656

5757
func TestCalculateEvenSplits(t *testing.T) {
58-
5958
testCases := []struct {
6059
// input size and source object
6160
size int64
@@ -69,47 +68,77 @@ func TestCalculateEvenSplits(t *testing.T) {
6968
{1, CopySrcOptions{Start: 0}, []int64{0}, []int64{0}},
7069

7170
{gb1, CopySrcOptions{Start: -1}, []int64{0, 536870912}, []int64{536870911, 1073741823}},
72-
{gb5, CopySrcOptions{Start: -1},
73-
[]int64{0, 536870912, 1073741824, 1610612736, 2147483648, 2684354560,
74-
3221225472, 3758096384, 4294967296, 4831838208},
75-
[]int64{536870911, 1073741823, 1610612735, 2147483647, 2684354559, 3221225471,
76-
3758096383, 4294967295, 4831838207, 5368709119},
71+
{
72+
gb5,
73+
CopySrcOptions{Start: -1},
74+
[]int64{
75+
0, 536870912, 1073741824, 1610612736, 2147483648, 2684354560,
76+
3221225472, 3758096384, 4294967296, 4831838208,
77+
},
78+
[]int64{
79+
536870911, 1073741823, 1610612735, 2147483647, 2684354559, 3221225471,
80+
3758096383, 4294967295, 4831838207, 5368709119,
81+
},
7782
},
7883

7984
// 2 part splits
80-
{gb5p1, CopySrcOptions{Start: -1},
81-
[]int64{0, 536870913, 1073741825, 1610612737, 2147483649, 2684354561,
82-
3221225473, 3758096385, 4294967297, 4831838209},
83-
[]int64{536870912, 1073741824, 1610612736, 2147483648, 2684354560, 3221225472,
84-
3758096384, 4294967296, 4831838208, 5368709120},
85+
{
86+
gb5p1,
87+
CopySrcOptions{Start: -1},
88+
[]int64{
89+
0, 536870913, 1073741825, 1610612737, 2147483649, 2684354561,
90+
3221225473, 3758096385, 4294967297, 4831838209,
91+
},
92+
[]int64{
93+
536870912, 1073741824, 1610612736, 2147483648, 2684354560, 3221225472,
94+
3758096384, 4294967296, 4831838208, 5368709120,
95+
},
8596
},
86-
{gb5p1, CopySrcOptions{Start: -1},
87-
[]int64{0, 536870913, 1073741825, 1610612737, 2147483649, 2684354561,
88-
3221225473, 3758096385, 4294967297, 4831838209},
89-
[]int64{536870912, 1073741824, 1610612736, 2147483648, 2684354560, 3221225472,
90-
3758096384, 4294967296, 4831838208, 5368709120},
97+
{
98+
gb5p1,
99+
CopySrcOptions{Start: -1},
100+
[]int64{
101+
0, 536870913, 1073741825, 1610612737, 2147483649, 2684354561,
102+
3221225473, 3758096385, 4294967297, 4831838209,
103+
},
104+
[]int64{
105+
536870912, 1073741824, 1610612736, 2147483648, 2684354560, 3221225472,
106+
3758096384, 4294967296, 4831838208, 5368709120,
107+
},
91108
},
92109

93110
// 3 part splits
94-
{gb10p1, CopySrcOptions{Start: -1},
95-
[]int64{0, 536870913, 1073741825, 1610612737, 2147483649, 2684354561,
111+
{
112+
gb10p1,
113+
CopySrcOptions{Start: -1},
114+
[]int64{
115+
0, 536870913, 1073741825, 1610612737, 2147483649, 2684354561,
96116
3221225473, 3758096385, 4294967297, 4831838209, 5368709121,
97117
5905580033, 6442450945, 6979321857, 7516192769, 8053063681,
98-
8589934593, 9126805505, 9663676417, 10200547329},
99-
[]int64{536870912, 1073741824, 1610612736, 2147483648, 2684354560,
118+
8589934593, 9126805505, 9663676417, 10200547329,
119+
},
120+
[]int64{
121+
536870912, 1073741824, 1610612736, 2147483648, 2684354560,
100122
3221225472, 3758096384, 4294967296, 4831838208, 5368709120,
101123
5905580032, 6442450944, 6979321856, 7516192768, 8053063680,
102-
8589934592, 9126805504, 9663676416, 10200547328, 10737418240},
124+
8589934592, 9126805504, 9663676416, 10200547328, 10737418240,
125+
},
103126
},
104-
{gb10p2, CopySrcOptions{Start: -1},
105-
[]int64{0, 536870913, 1073741826, 1610612738, 2147483650, 2684354562,
127+
{
128+
gb10p2,
129+
CopySrcOptions{Start: -1},
130+
[]int64{
131+
0, 536870913, 1073741826, 1610612738, 2147483650, 2684354562,
106132
3221225474, 3758096386, 4294967298, 4831838210, 5368709122,
107133
5905580034, 6442450946, 6979321858, 7516192770, 8053063682,
108-
8589934594, 9126805506, 9663676418, 10200547330},
109-
[]int64{536870912, 1073741825, 1610612737, 2147483649, 2684354561,
134+
8589934594, 9126805506, 9663676418, 10200547330,
135+
},
136+
[]int64{
137+
536870912, 1073741825, 1610612737, 2147483649, 2684354561,
110138
3221225473, 3758096385, 4294967297, 4831838209, 5368709121,
111139
5905580033, 6442450945, 6979321857, 7516192769, 8053063681,
112-
8589934593, 9126805505, 9663676417, 10200547329, 10737418241},
140+
8589934593, 9126805505, 9663676417, 10200547329, 10737418241,
141+
},
113142
},
114143
}
115144

api-error-response_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ func TestHttpRespToErrorResponse(t *testing.T) {
174174
// expected results.
175175
expectedResult error
176176
// flag indicating whether tests should pass.
177-
178177
}{
179178
{"minio-bucket", "", inputResponses[0], expectedErrResponse[0]},
180179
{"minio-bucket", "", inputResponses[1], expectedErrResponse[1]},

api-get-object-file.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (c *Client) FGetObject(ctx context.Context, bucketName, objectName, filePat
5757
objectDir, _ := filepath.Split(filePath)
5858
if objectDir != "" {
5959
// Create any missing top level directories.
60-
if err := os.MkdirAll(objectDir, 0700); err != nil {
60+
if err := os.MkdirAll(objectDir, 0o700); err != nil {
6161
return err
6262
}
6363
}
@@ -72,7 +72,7 @@ func (c *Client) FGetObject(ctx context.Context, bucketName, objectName, filePat
7272
filePartPath := filePath + objectStat.ETag + ".part.minio"
7373

7474
// If exists, open in append mode. If not create it as a part file.
75-
filePart, err := os.OpenFile(filePartPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0600)
75+
filePart, err := os.OpenFile(filePartPath, os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0o600)
7676
if err != nil {
7777
return err
7878
}

api-list.go

-1
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,6 @@ func (c *Client) listIncompleteUploads(ctx context.Context, bucketName, objectPr
774774
}(objectMultipartStatCh)
775775
// return.
776776
return objectMultipartStatCh
777-
778777
}
779778

780779
// listMultipartUploadsQuery - (List Multipart Uploads).

api-put-object-multipart.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ import (
3838
)
3939

4040
func (c *Client) putObjectMultipart(ctx context.Context, bucketName, objectName string, reader io.Reader, size int64,
41-
opts PutObjectOptions) (info UploadInfo, err error) {
41+
opts PutObjectOptions,
42+
) (info UploadInfo, err error) {
4243
info, err = c.putObjectMultipartNoStream(ctx, bucketName, objectName, reader, opts)
4344
if err != nil {
4445
errResp := ToErrorResponse(err)
@@ -240,7 +241,8 @@ func (c *Client) initiateMultipartUpload(ctx context.Context, bucketName, object
240241

241242
// uploadPart - Uploads a part in a multipart upload.
242243
func (c *Client) uploadPart(ctx context.Context, bucketName, objectName, uploadID string, reader io.Reader,
243-
partNumber int, md5Base64, sha256Hex string, size int64, sse encrypt.ServerSide) (ObjectPart, error) {
244+
partNumber int, md5Base64, sha256Hex string, size int64, sse encrypt.ServerSide,
245+
) (ObjectPart, error) {
244246
// Input validation.
245247
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
246248
return ObjectPart{}, err
@@ -311,7 +313,8 @@ func (c *Client) uploadPart(ctx context.Context, bucketName, objectName, uploadI
311313

312314
// completeMultipartUpload - Completes a multipart upload by assembling previously uploaded parts.
313315
func (c *Client) completeMultipartUpload(ctx context.Context, bucketName, objectName, uploadID string,
314-
complete completeMultipartUpload, opts PutObjectOptions) (UploadInfo, error) {
316+
complete completeMultipartUpload, opts PutObjectOptions,
317+
) (UploadInfo, error) {
315318
// Input validation.
316319
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
317320
return UploadInfo{}, err
@@ -392,5 +395,4 @@ func (c *Client) completeMultipartUpload(ctx context.Context, bucketName, object
392395
Expiration: expTime,
393396
ExpirationRuleID: ruleID,
394397
}, nil
395-
396398
}

api-put-object-streaming.go

+7-5
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ import (
4242
// - Any reader which has a method 'ReadAt()'
4343
//
4444
func (c *Client) putObjectMultipartStream(ctx context.Context, bucketName, objectName string,
45-
reader io.Reader, size int64, opts PutObjectOptions) (info UploadInfo, err error) {
46-
45+
reader io.Reader, size int64, opts PutObjectOptions,
46+
) (info UploadInfo, err error) {
4747
if !isObject(reader) && isReadAt(reader) && !opts.SendContentMd5 {
4848
// Verify if the reader implements ReadAt and it is not a *minio.Object then we will use parallel uploader.
4949
info, err = c.putObjectMultipartStreamFromReadAt(ctx, bucketName, objectName, reader.(io.ReaderAt), size, opts)
@@ -91,7 +91,8 @@ type uploadPartReq struct {
9191
// cleaned automatically when the caller i.e http client closes the
9292
// stream after uploading all the contents successfully.
9393
func (c *Client) putObjectMultipartStreamFromReadAt(ctx context.Context, bucketName, objectName string,
94-
reader io.ReaderAt, size int64, opts PutObjectOptions) (info UploadInfo, err error) {
94+
reader io.ReaderAt, size int64, opts PutObjectOptions,
95+
) (info UploadInfo, err error) {
9596
// Input validation.
9697
if err = s3utils.CheckValidBucketName(bucketName); err != nil {
9798
return UploadInfo{}, err
@@ -147,7 +148,7 @@ func (c *Client) putObjectMultipartStreamFromReadAt(ctx context.Context, bucketN
147148
}
148149
close(uploadPartsCh)
149150

150-
var partsBuf = make([][]byte, opts.getNumThreads())
151+
partsBuf := make([][]byte, opts.getNumThreads())
151152
for i := range partsBuf {
152153
partsBuf[i] = make([]byte, 0, partSize)
153154
}
@@ -241,7 +242,8 @@ func (c *Client) putObjectMultipartStreamFromReadAt(ctx context.Context, bucketN
241242
}
242243

243244
func (c *Client) putObjectMultipartStreamOptionalChecksum(ctx context.Context, bucketName, objectName string,
244-
reader io.Reader, size int64, opts PutObjectOptions) (info UploadInfo, err error) {
245+
reader io.Reader, size int64, opts PutObjectOptions,
246+
) (info UploadInfo, err error) {
245247
// Input validation.
246248
if err = s3utils.CheckValidBucketName(bucketName); err != nil {
247249
return UploadInfo{}, err

api-put-object.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ func (a completedParts) Less(i, j int) bool { return a[i].PartNumber < a[j].Part
229229
//
230230
// NOTE: Upon errors during upload multipart operation is entirely aborted.
231231
func (c *Client) PutObject(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64,
232-
opts PutObjectOptions) (info UploadInfo, err error) {
232+
opts PutObjectOptions,
233+
) (info UploadInfo, err error) {
233234
if objectSize < 0 && opts.DisableMultipart {
234235
return UploadInfo{}, errors.New("object size must be provided with disable multipart upload")
235236
}

api-putobject-snowball.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (c Client) PutObjectsSnowball(ctx context.Context, bucketName string, opts
133133
return f, st.Size(), nil
134134
}
135135
}
136-
var flush = func() error { return nil }
136+
flush := func() error { return nil }
137137
if !opts.Compress {
138138
if !opts.InMemory {
139139
// Insert buffer for writes.

api-select.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ func (s *SelectResults) start(pipeWriter *io.PipeWriter) {
519519
go func() {
520520
for {
521521
var prelude preludeInfo
522-
var headers = make(http.Header)
522+
headers := make(http.Header)
523523
var err error
524524

525525
// Create CRC code
@@ -624,7 +624,7 @@ func (p preludeInfo) PayloadLen() int64 {
624624
// the struct,
625625
func processPrelude(prelude io.Reader, crc hash.Hash32) (preludeInfo, error) {
626626
var err error
627-
var pInfo = preludeInfo{}
627+
pInfo := preludeInfo{}
628628

629629
// reads total length of the message (first 4 bytes)
630630
pInfo.totalLen, err = extractUint32(prelude)
@@ -752,7 +752,6 @@ func checkCRC(r io.Reader, expect uint32) error {
752752

753753
if msgCRC != expect {
754754
return fmt.Errorf("Checksum Mismatch, MessageCRC of 0x%X does not equal expected CRC of 0x%X", msgCRC, expect)
755-
756755
}
757756
return nil
758757
}

api.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ func (c *Client) executeMethod(ctx context.Context, method string, metadata requ
537537

538538
var retryable bool // Indicates if request can be retried.
539539
var bodySeeker io.Seeker // Extracted seeker from io.Reader.
540-
var reqRetry = MaxRetry // Indicates how many times we can retry the request
540+
reqRetry := MaxRetry // Indicates how many times we can retry the request
541541

542542
if metadata.contentBody != nil {
543543
// Check if body is seekable then it is retryable.

bucket-cache_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ func TestGetBucketLocationRequest(t *testing.T) {
126126
}
127127

128128
return req, nil
129-
130129
}
131130
// Info for 'Client' creation.
132131
// Will be used as arguments for 'NewClient'.

core.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func (c Core) CopyObject(ctx context.Context, sourceBucket, sourceObject, destBu
6363
// CopyObjectPart - creates a part in a multipart upload by copying (a
6464
// part of) an existing object.
6565
func (c Core) CopyObjectPart(ctx context.Context, srcBucket, srcObject, destBucket, destObject string, uploadID string,
66-
partID int, startOffset, length int64, metadata map[string]string) (p CompletePart, err error) {
67-
66+
partID int, startOffset, length int64, metadata map[string]string,
67+
) (p CompletePart, err error) {
6868
return c.copyObjectPartDo(ctx, srcBucket, srcObject, destBucket, destObject, uploadID,
6969
partID, startOffset, length, metadata)
7070
}

core_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ package minio
2020
import (
2121
"bytes"
2222
"context"
23+
"math/rand"
2324
"net/http"
2425
"os"
2526
"strconv"
2627
"testing"
2728
"time"
2829

29-
"math/rand"
30-
3130
"github.com/minio/minio-go/v7/pkg/credentials"
3231
)
3332

examples/minio/getbucketreplicationmetrics.go

-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func main() {
4343
Creds: credentials.NewStaticV4("YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", ""),
4444
Secure: true,
4545
})
46-
4746
if err != nil {
4847
log.Fatalln(err)
4948
}

0 commit comments

Comments
 (0)