Move to go1.8 for all builds. (#2019)

This commit is contained in:
Harshavardhana
2017-02-17 21:29:53 +01:00
committed by Anis Elleuch
parent 7483cdebfb
commit d7a3a0bce3
12 changed files with 41 additions and 53 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ env:
- ARCH=i686
go:
- 1.7.3
- 1.8
script:
- make test GOFLAGS="-race"
+1 -1
View File
@@ -1,4 +1,4 @@
FROM golang:1.7-alpine
FROM golang:1.8-alpine
WORKDIR /go/src/app
+4
View File
@@ -8,11 +8,15 @@ clone_folder: c:\gopath\src\github.com\minio\mc
# environment variables
environment:
GOVERSION: 1.8
GOPATH: c:\gopath
# scripts that run after cloning repository
install:
- set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
- rmdir c:\go /s /q
- appveyor DownloadFile https://storage.googleapis.com/golang/go%GOVERSION%.windows-amd64.zip
- 7z x go%GOVERSION%.windows-amd64.zip -y -oC:\ > NUL
- go version
- go env
+1 -1
View File
@@ -26,7 +26,7 @@ import (
// mc configuration related constants.
const (
minGoVersion = ">= 1.7.1" // mc requires at least Go v1.7.1
minGoVersion = ">= 1.8" // mc requires at least Go v1.8
)
const (
+3 -3
View File
@@ -116,10 +116,10 @@ func (s *TestSuite) TestHumanizedTime(c *C) {
}
func (s *TestSuite) TestVersions(c *C) {
v1, e := version.NewVersion("1.7.1")
v2, e := version.NewVersion("1.6.3")
v1, e := version.NewVersion("1.8")
v2, e := version.NewVersion("1.7")
c.Assert(e, IsNil)
constraint, e := version.NewConstraint(">= 1.7.1")
constraint, e := version.NewConstraint(">= 1.8")
c.Assert(e, IsNil)
c.Assert(constraint.Check(v1), Equals, true)
c.Assert(constraint.Check(v2), Equals, false)
+14 -23
View File
@@ -212,10 +212,12 @@ type Object struct {
reqCh chan<- getRequest
resCh <-chan getResponse
doneCh chan<- struct{}
prevOffset int64
currOffset int64
objectInfo ObjectInfo
// Ask lower level to initiate data fetching based on currOffset
seekData bool
// Keeps track of closed call.
isClosed bool
@@ -258,6 +260,10 @@ func (o *Object) doGetRequest(request getRequest) (getResponse, error) {
if response.Error != nil {
return response, response.Error
}
// Data are ready on the wire, no need to reinitiate connection in lower level
o.seekData = false
return response, nil
}
@@ -266,8 +272,6 @@ func (o *Object) doGetRequest(request getRequest) (getResponse, error) {
func (o *Object) setOffset(bytesRead int64) error {
// Update the currentOffset.
o.currOffset += bytesRead
// Save the current offset as previous offset.
o.prevOffset = o.currOffset
if o.currOffset >= o.objectInfo.Size {
return io.EOF
@@ -303,22 +307,9 @@ func (o *Object) Read(b []byte) (n int, err error) {
readReq.isFirstReq = true
}
// Verify if offset has changed and currOffset is greater than
// previous offset. Perhaps due to Seek().
offsetChange := o.prevOffset - o.currOffset
if offsetChange < 0 {
offsetChange = -offsetChange
}
if offsetChange > 0 {
// Fetch the new reader at the current offset again.
readReq.Offset = o.currOffset
readReq.DidOffsetChange = true
} else {
// No offset changes no need to fetch new reader, continue
// reading.
readReq.DidOffsetChange = false
readReq.Offset = 0
}
// Ask to establish a new data fetch routine based on seekData flag
readReq.DidOffsetChange = o.seekData
readReq.Offset = o.currOffset
// Send and receive from the first request.
response, err := o.doGetRequest(readReq)
@@ -430,8 +421,6 @@ func (o *Object) ReadAt(b []byte, offset int64) (n int, err error) {
if !o.objectInfoSet {
// Update the currentOffset.
o.currOffset += bytesRead
// Save the current offset as previous offset.
o.prevOffset = o.currOffset
} else {
// If this was not the first request update
// the offsets and compare against objectInfo
@@ -492,8 +481,6 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) {
return 0, err
}
}
// Save current offset as previous offset.
o.prevOffset = o.currOffset
// Switch through whence.
switch whence {
@@ -527,6 +514,10 @@ func (o *Object) Seek(offset int64, whence int) (n int64, err error) {
if o.prevErr == io.EOF {
o.prevErr = nil
}
// Ask lower level to fetch again from source
o.seekData = true
// Return the effective offset.
return o.currOffset, nil
}
+1 -1
View File
@@ -161,7 +161,7 @@ func hashCopyN(hashAlgorithms map[string]hash.Hash, hashSums map[string][]byte,
for k, v := range hashAlgorithms {
hashSums[k] = v.Sum(nil)
}
return size, err
return size, nil
}
// getUploadID - fetch upload id if already present for an object name
+1 -3
View File
@@ -114,9 +114,7 @@ func (c Client) putObjectMultipartStream(bucketName, objectName string, reader i
// Calculates hash sums while copying partSize bytes into tmpBuffer.
prtSize, rErr := hashCopyN(hashAlgos, hashSums, tmpBuffer, reader, partSize)
if rErr != nil {
if rErr != io.EOF {
return 0, rErr
}
return 0, rErr
}
var reader io.Reader
+4 -6
View File
@@ -209,6 +209,9 @@ func (c Client) putObjectSingle(bucketName, objectName string, reader io.Reader,
// Initialize a new temporary buffer.
tmpBuffer := new(bytes.Buffer)
size, err = hashCopyN(hashAlgos, hashSums, tmpBuffer, reader, size)
if err != nil {
return 0, err
}
reader = bytes.NewReader(tmpBuffer.Bytes())
tmpBuffer.Reset()
} else {
@@ -229,12 +232,7 @@ func (c Client) putObjectSingle(bucketName, objectName string, reader io.Reader,
}
reader = tmpFile
}
// Return error if its not io.EOF.
if err != nil {
if err != io.EOF {
return 0, err
}
}
// Execute put object.
st, err := c.putObjectDo(bucketName, objectName, reader, hashSums["md5"], hashSums["sha256"], size, metaData)
if err != nil {
+2 -7
View File
@@ -81,7 +81,7 @@ type Client struct {
// Global constants.
const (
libraryName = "minio-go"
libraryVersion = "2.0.3"
libraryVersion = "2.0.4"
)
// User Agent should always following the below style.
@@ -588,7 +588,7 @@ func (c Client) newRequest(method string, metadata requestMetadata) (req *http.R
}
// Initialize a new HTTP request for the method.
req, err = http.NewRequest(method, targetURL.String(), nil)
req, err = http.NewRequest(method, targetURL.String(), metadata.contentBody)
if err != nil {
return nil, err
}
@@ -608,11 +608,6 @@ func (c Client) newRequest(method string, metadata requestMetadata) (req *http.R
return req, nil
}
// Set content body if available.
if metadata.contentBody != nil {
req.Body = ioutil.NopCloser(metadata.contentBody)
}
// FIXME: Enable this when Google Cloud Storage properly supports 100-continue.
// Skip setting 'expect' header for Google Cloud Storage, there
// are some known issues - https://github.com/restic/restic/issues/520
+6 -4
View File
@@ -41,11 +41,13 @@ type CopyConditions struct {
conditions []copyCondition
}
// NewCopyConditions - Instantiate new list of conditions.
// NewCopyConditions - Instantiate new list of conditions. This
// function is left behind for backward compatibility. The idiomatic
// way to set an empty set of copy conditions is,
// ``copyConditions := CopyConditions{}``.
//
func NewCopyConditions() CopyConditions {
return CopyConditions{
conditions: make([]copyCondition, 0),
}
return CopyConditions{}
}
// SetMatchETag - set match etag.
+3 -3
View File
@@ -50,10 +50,10 @@
"revisionTime": "2015-10-24T22:24:27-07:00"
},
{
"checksumSHA1": "2FrFoR0UtufaCGRxM4UxP1fR3LM=",
"checksumSHA1": "InJ8MZLIDbv2KJk2tiyHUHOuRHE=",
"path": "github.com/minio/minio-go",
"revision": "952412b95ae05cced91069ddc97b108a675ca1d1",
"revisionTime": "2017-01-05T09:15:05Z"
"revision": "7a3619e41885dcbcfafee193c10eb80530c2be53",
"revisionTime": "2017-02-17T20:03:45Z"
},
{
"checksumSHA1": "qTxOBp3GVxCC70ykb7Hxg6UgWwA=",