diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0b3d9fcc3..97a1710f8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,10 +29,10 @@ jobs: env: GO111MODULE: 'on' inputs: - version: '1.17.9' + version: '1.19.2' - script: | - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.43.0 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.46.2 echo 'Installation complete' ./bin/golangci-lint --version ./bin/golangci-lint run e2etest @@ -116,7 +116,7 @@ jobs: steps: - task: GoTool@0 inputs: - version: '1.17.9' + version: '1.19.2' # Running E2E Tests on Linux - AMD64 - script: | @@ -204,7 +204,7 @@ jobs: - task: GoTool@0 name: 'Set_up_Golang' inputs: - version: '1.17.9' + version: '1.19.2' - task: DownloadSecureFile@1 name: ciGCSServiceAccountKey displayName: 'Download GCS Service Account Key' diff --git a/e2etest/arm.go b/e2etest/arm.go index b01679f25..1cc3f9c62 100644 --- a/e2etest/arm.go +++ b/e2etest/arm.go @@ -4,7 +4,7 @@ import ( "encoding/json" "fmt" "github.com/Azure/go-autorest/autorest/adal" - "io/ioutil" + "io" "net/http" "reflect" "strconv" @@ -53,7 +53,7 @@ func ResolveAzureAsyncOperation(OAuth *adal.ServicePrincipalToken, uri string, p } var buf []byte - buf, err = ioutil.ReadAll(resp.Body) + buf, err = io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body (resp code 200): %w", err) } @@ -68,7 +68,7 @@ func ResolveAzureAsyncOperation(OAuth *adal.ServicePrincipalToken, uri string, p } if resp.StatusCode != 200 { - rBody, err := ioutil.ReadAll(resp.Body) + rBody, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body (resp code %d): %w", resp.StatusCode, err) } diff --git a/e2etest/factory.go b/e2etest/factory.go index 382bddeb5..5217efca0 100644 --- a/e2etest/factory.go +++ b/e2etest/factory.go @@ -23,8 +23,8 @@ package e2etest import ( "context" "fmt" - "io/ioutil" "net/url" + "os" "path" "runtime" "strings" @@ -184,7 +184,7 @@ func (TestResourceFactory) CreateNewFileShareSnapshot(c asserter, fileShare azfi } func (TestResourceFactory) CreateLocalDirectory(c asserter) (dstDirName string) { - dstDirName, err := ioutil.TempDir("", "AzCopyLocalTest") + dstDirName, err := os.MkdirTemp("","AzCopyLocalTest") c.AssertNoErr(err) return } diff --git a/e2etest/managedDisks.go b/e2etest/managedDisks.go index 5a19290aa..e7166dfb6 100644 --- a/e2etest/managedDisks.go +++ b/e2etest/managedDisks.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "net/url" "path" @@ -77,7 +77,7 @@ func (config *ManagedDiskConfig) GetAccess() (*url.URL, error) { return nil, fmt.Errorf("failed to get access (async op): %w", err) } } else { // error - rBody, err := ioutil.ReadAll(resp.Body) + rBody, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body (resp code %d): %w", resp.StatusCode, err) } @@ -85,7 +85,7 @@ func (config *ManagedDiskConfig) GetAccess() (*url.URL, error) { return nil, fmt.Errorf("failed to get access (resp code %d): %s", resp.StatusCode, string(rBody)) } } else { // immediate response - rBody, err := ioutil.ReadAll(resp.Body) + rBody, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %w", err) } @@ -132,7 +132,7 @@ func (config *ManagedDiskConfig) RevokeAccess() error { return err } - rBody, err := ioutil.ReadAll(resp.Body) + rBody, err := io.ReadAll(resp.Body) if err != nil { return fmt.Errorf("failed to read response body (resp code %d): %w", resp.StatusCode, err) } diff --git a/e2etest/scenario_helpers.go b/e2etest/scenario_helpers.go index 10983d021..25402884e 100644 --- a/e2etest/scenario_helpers.go +++ b/e2etest/scenario_helpers.go @@ -26,7 +26,7 @@ import ( "context" "crypto/md5" "fmt" - "io/ioutil" + "io" "net/url" "os" "path" @@ -67,7 +67,7 @@ var specialNames = []string{ // note: this is to emulate the list-of-files flag // nolint func (scenarioHelper) generateListOfFiles(c asserter, fileList []string) (path string) { - parentDirName, err := ioutil.TempDir("", "AzCopyLocalTest") + parentDirName, err := os.MkdirTemp("", "AzCopyLocalTest") c.AssertNoErr(err) // create the file @@ -77,14 +77,14 @@ func (scenarioHelper) generateListOfFiles(c asserter, fileList []string) (path s // pipe content into it content := strings.Join(fileList, "\n") - err = ioutil.WriteFile(path, []byte(content), common.DEFAULT_FILE_PERM) + err = os.WriteFile(path, []byte(content), common.DEFAULT_FILE_PERM) c.AssertNoErr(err) return } // nolint func (scenarioHelper) generateLocalDirectory(c asserter) (dstDirName string) { - dstDirName, err := ioutil.TempDir("", "AzCopyLocalTest") + dstDirName, err := os.MkdirTemp("", "AzCopyLocalTest") c.AssertNoErr(err) return } @@ -101,7 +101,7 @@ func (scenarioHelper) generateLocalFile(filePath string, fileSize int) ([]byte, } // write to file and return the data - err = ioutil.WriteFile(filePath, bigBuff, common.DEFAULT_FILE_PERM) + err = os.WriteFile(filePath, bigBuff, common.DEFAULT_FILE_PERM) return bigBuff, err } @@ -529,7 +529,7 @@ func (s scenarioHelper) downloadBlobContent(a asserter, options downloadContentO retryReader := downloadResp.Body(azblob.RetryReaderOptions{}) defer retryReader.Close() - destData, err := ioutil.ReadAll(retryReader) + destData, err := io.ReadAll(retryReader) a.AssertNoErr(err) return destData[:] } @@ -910,7 +910,7 @@ func (s scenarioHelper) downloadFileContent(a asserter, options downloadContentO retryReader := downloadResp.Body(azfile.RetryReaderOptions{}) defer retryReader.Close() // The client must close the response body when finished with it - destData, err := ioutil.ReadAll(retryReader) + destData, err := io.ReadAll(retryReader) a.AssertNoErr(err) downloadResp.Body(azfile.RetryReaderOptions{}) return destData diff --git a/e2etest/scenario_os_helpers_for_windows.go b/e2etest/scenario_os_helpers_for_windows.go index 7a2206e35..ad7fde9ae 100644 --- a/e2etest/scenario_os_helpers_for_windows.go +++ b/e2etest/scenario_os_helpers_for_windows.go @@ -39,7 +39,7 @@ import ( type osScenarioHelper struct{} // set file attributes to test file -func (osScenarioHelper) setAttributesForLocalFile(filePath string, attrList []string) error { +func (osScenarioHelper) setAttributesForLocalFile(filePath string, attrList []string) error { //nolint:golint,unused lpFilePath, err := syscall.UTF16PtrFromString(filePath) if err != nil { return err @@ -65,7 +65,7 @@ func (osScenarioHelper) setAttributesForLocalFile(filePath string, attrList []st return err } -func (s osScenarioHelper) setAttributesForLocalFiles(c asserter, dirPath string, fileList []string, attrList []string) { +func (s osScenarioHelper) setAttributesForLocalFiles(c asserter, dirPath string, fileList []string, attrList []string) { //nolint:golint,unused for _, fileName := range fileList { err := s.setAttributesForLocalFile(filepath.Join(dirPath, fileName), attrList) c.AssertNoErr(err)