From e5aec8051fd78429a44647e17dff3ad1ef80b895 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Thu, 3 Oct 2024 15:15:36 -0700 Subject: [PATCH] Update to the latest two versions of Go (#23536) * Update to the latest two versions of Go Remove setting nocoverageredesign as the underlying issue has been fixed, so it's no longer required. Update to latest version of golangci-lint. * clean up lint --- eng/pipelines/mgmt-auto-release.yml | 2 +- .../jobs/archetype-sdk-client-samples.yml | 20 ++++++------- .../templates/jobs/archetype-sdk-client.yml | 2 +- .../jobs/archetype-sdk-eng-client.yml | 20 ++++++------- .../templates/jobs/mgmt-mock-test.yml | 2 +- .../stages/ci-platform-matrix-complete.json | 28 ++----------------- .../templates/stages/ci-platform-matrix.json | 28 ++----------------- .../templates/stages/platform-matrix.json | 23 ++------------- eng/pipelines/templates/variables/globals.yml | 2 +- eng/scripts/automation_init.sh | 6 ++-- sdk/azcore/messaging/cloud_event_test.go | 6 ++-- sdk/internal/log/log.go | 2 +- sdk/internal/recording/recording.go | 2 +- sdk/internal/recording/server.go | 9 +++--- 14 files changed, 41 insertions(+), 111 deletions(-) diff --git a/eng/pipelines/mgmt-auto-release.yml b/eng/pipelines/mgmt-auto-release.yml index f91520ee6fc0..95823664275c 100644 --- a/eng/pipelines/mgmt-auto-release.yml +++ b/eng/pipelines/mgmt-auto-release.yml @@ -31,7 +31,7 @@ extends: - task: GoTool@0 inputs: - version: '1.22.0' + version: '1.23.2' - task: ShellScript@2 inputs: diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client-samples.yml b/eng/pipelines/templates/jobs/archetype-sdk-client-samples.yml index d3ff01bd333e..2439d16060ca 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client-samples.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client-samples.yml @@ -24,24 +24,22 @@ stages: pool.name: azsdk-pool-mms-win-2022-general image.name: MMS2022 go.version: '1.18.10' - Linux_Go121: + Linux_Go122: pool.name: azsdk-pool-mms-ubuntu-2004-general image.name: MMSUbuntu20.04 - go.version: '1.21.7' - Windows_Go121: + go.version: '1.22.8' + Windows_Go122: pool.name: azsdk-pool-mms-win-2022-general image.name: MMS2022 - go.version: '1.21.7' - Linux_Go122: + go.version: '1.22.8' + Linux_Go123: pool.name: azsdk-pool-mms-ubuntu-2004-general image.name: MMSUbuntu20.04 - go.version: '1.22.0' - GOEXPERIMENT: nocoverageredesign - Windows_Go122: + go.version: '1.23.2' + Windows_Go123: pool.name: azsdk-pool-mms-win-2022-general image.name: MMS2022 - go.version: '1.22.0' - GOEXPERIMENT: nocoverageredesign + go.version: '1.23.2' pool: name: $(pool.name) vmImage: $(image.name) @@ -75,7 +73,7 @@ stages: steps: - task: GoTool@0 inputs: - version: '1.22.0' + version: '1.23.2' displayName: "Select Go Version" - template: ../steps/create-go-workspace.yml diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 0a4833c63952..ab01b046de25 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -153,7 +153,7 @@ extends: - task: GoTool@0 inputs: - version: '1.22.0' + version: '1.23.2' displayName: "Select Go Version" - template: /eng/pipelines/templates/steps/create-go-workspace.yml@self diff --git a/eng/pipelines/templates/jobs/archetype-sdk-eng-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-eng-client.yml index 8b4f2d1f7319..095acc92d9bf 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-eng-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-eng-client.yml @@ -40,24 +40,22 @@ stages: pool.name: azsdk-pool-mms-win-2022-general image.name: MMS2022 go.version: '1.18.10' - Linux_Go121: + Linux_Go122: pool.name: azsdk-pool-mms-ubuntu-2004-general image.name: MMSUbuntu20.04 - go.version: '1.21.7' - Windows_Go121: + go.version: '1.22.8' + Windows_Go122: pool.name: azsdk-pool-mms-win-2022-general image.name: MMS2022 - go.version: '1.21.7' - Linux_Go122: + go.version: '1.22.8' + Linux_Go123: pool.name: azsdk-pool-mms-ubuntu-2004-general image.name: MMSUbuntu20.04 - go.version: '1.22.0' - GOEXPERIMENT: nocoverageredesign - Windows_Go122: + go.version: '1.23.2' + Windows_Go123: pool.name: azsdk-pool-mms-win-2022-general image.name: MMS2022 - go.version: '1.22.0' - GOEXPERIMENT: nocoverageredesign + go.version: '1.23.2' generate.bom: true pool: name: $(pool.name) @@ -97,7 +95,7 @@ stages: - task: GoTool@0 inputs: - version: '1.22.0' + version: '1.23.2' displayName: "Select Go Version" - template: ../steps/create-go-workspace.yml diff --git a/eng/pipelines/templates/jobs/mgmt-mock-test.yml b/eng/pipelines/templates/jobs/mgmt-mock-test.yml index 6903f4910692..03cbad1fdbb2 100644 --- a/eng/pipelines/templates/jobs/mgmt-mock-test.yml +++ b/eng/pipelines/templates/jobs/mgmt-mock-test.yml @@ -19,7 +19,7 @@ jobs: displayName: 'Install autorest' - task: GoTool@0 inputs: - version: '1.22.0' + version: '1.23.2' displayName: "Select Go Version" - template: /eng/pipelines/templates/steps/create-go-workspace.yml diff --git a/eng/pipelines/templates/stages/ci-platform-matrix-complete.json b/eng/pipelines/templates/stages/ci-platform-matrix-complete.json index ff3e3ddbcaf5..2b172076220e 100644 --- a/eng/pipelines/templates/stages/ci-platform-matrix-complete.json +++ b/eng/pipelines/templates/stages/ci-platform-matrix-complete.json @@ -10,30 +10,6 @@ "OSVmImage": "env:LINUXVMIMAGE", "Pool": "env:LINUXPOOL" } }, - "go.version": ["1.21.7", "1.18.10"] - }, - "include": [ - { - "WindowsNoCoverage": { - "windows-22_1220_nocoverage": - { - "go.version": "1.22.0", - "GOEXPERIMENT": "nocoverageredesign", - "generate.bom": "true", - "OSVmImage": "env:WINDOWSVMIMAGE", - "Pool":"env:WINDOWSPOOL" - } - } - }, - { - "LinuxNoCoverage": { - "ubuntu-2004_nocoverage": { - "go.version": "1.22.0", - "GOEXPERIMENT": "nocoverageredesign", - "OSVmImage": "env:LINUXVMIMAGE", - "Pool": "env:LINUXPOOL" - } - } - } - ] + "go.version": ["1.23.2", "1.22.8", "1.18.10"] + } } diff --git a/eng/pipelines/templates/stages/ci-platform-matrix.json b/eng/pipelines/templates/stages/ci-platform-matrix.json index 2e4f2a703ead..0c68cba4db75 100644 --- a/eng/pipelines/templates/stages/ci-platform-matrix.json +++ b/eng/pipelines/templates/stages/ci-platform-matrix.json @@ -10,30 +10,6 @@ "OSVmImage": "env:LINUXVMIMAGE", "Pool": "env:LINUXPOOL" } }, - "go.version": ["1.21.7"] - }, - "include": [ - { - "WindowsNoCoverage": { - "windows-22_1220_nocoverage": - { - "go.version": "1.22.0", - "GOEXPERIMENT": "nocoverageredesign", - "generate.bom": "true", - "OSVmImage": "env:WINDOWSVMIMAGE", - "Pool":"env:WINDOWSPOOL" - } - } - }, - { - "LinuxNoCoverage": { - "ubuntu-2004_nocoverage": { - "go.version": "1.22.0", - "GOEXPERIMENT": "nocoverageredesign", - "OSVmImage": "env:LINUXVMIMAGE", - "Pool": "env:LINUXPOOL" - } - } - } - ] + "go.version": ["1.23.2", "1.22.8"] + } } diff --git a/eng/pipelines/templates/stages/platform-matrix.json b/eng/pipelines/templates/stages/platform-matrix.json index 35c6034e2dcd..94320b5c8188 100644 --- a/eng/pipelines/templates/stages/platform-matrix.json +++ b/eng/pipelines/templates/stages/platform-matrix.json @@ -12,25 +12,8 @@ }, "GoVersion": [ "1.18.10", - "1.21.7" + "1.22.8", + "1.23.2" ] - }, - "include": [ - { - "Agent": { - "ubuntu-20.04": { - "OSVmImage": "env:LINUXVMIMAGE", - "Pool": "env:LINUXPOOL" - }, - "windows-2022": { - "OSVmImage": "env:WINDOWSVMIMAGE", - "Pool": "env:WINDOWSPOOL" - } - }, - "GoVersion": [ - "1.22.0" - ], - "GOEXPERIMENT": "nocoverageredesign" - } - ] + } } diff --git a/eng/pipelines/templates/variables/globals.yml b/eng/pipelines/templates/variables/globals.yml index c4b9fdf3ebba..85855678be3f 100644 --- a/eng/pipelines/templates/variables/globals.yml +++ b/eng/pipelines/templates/variables/globals.yml @@ -1,5 +1,5 @@ variables: - GoLintCLIVersion: 'v1.59.0' + GoLintCLIVersion: 'v1.61.0' Package.EnableSBOMSigning: true # Enable go native component governance detection # https://docs.opensource.microsoft.com/tools/cg/index.html diff --git a/eng/scripts/automation_init.sh b/eng/scripts/automation_init.sh index 897620f593d5..1fe77dd6505b 100644 --- a/eng/scripts/automation_init.sh +++ b/eng/scripts/automation_init.sh @@ -16,10 +16,10 @@ outputFile="$(realpath $outputFile)" echo "output json file: $outputFile" TMPDIR="/tmp" -if [ ! "$(go version | awk '{print $3}' | cut -c 3-6)" = "1.22" ] +if [ ! "$(go version | awk '{print $3}' | cut -c 3-6)" = "1.23" ] then - wget -q https://golang.org/dl/go1.22.0.linux-amd64.tar.gz - tar -C $TMPDIR -xzf go1.22.0.linux-amd64.tar.gz + wget -q https://golang.org/dl/go1.23.2.linux-amd64.tar.gz + tar -C $TMPDIR -xzf go1.23.2.linux-amd64.tar.gz export GOROOT=$TMPDIR/go export PATH=$GOROOT/bin:$PATH fi diff --git a/sdk/azcore/messaging/cloud_event_test.go b/sdk/azcore/messaging/cloud_event_test.go index b64fa2c54912..5d25dedfc123 100644 --- a/sdk/azcore/messaging/cloud_event_test.go +++ b/sdk/azcore/messaging/cloud_event_test.go @@ -5,7 +5,7 @@ package messaging import ( "encoding/json" - "io/ioutil" + "os" "testing" "time" @@ -110,7 +110,7 @@ func TestCloudEventUnmarshalFull(t *testing.T) { func TestCloudEventUnmarshalFull_InteropWithPython(t *testing.T) { // this event is a Python serialized CloudEvent - text, err := ioutil.ReadFile("testdata/cloudevent_binary_with_extensions.json") + text, err := os.ReadFile("testdata/cloudevent_binary_with_extensions.json") require.NoError(t, err) var ce *CloudEvent @@ -141,7 +141,7 @@ func TestCloudEventUnmarshalFull_InteropWithPython(t *testing.T) { } func TestCloudEventUnmarshalRequiredFieldsOnly(t *testing.T) { - text, err := ioutil.ReadFile("testdata/cloudevent_required_only.json") + text, err := os.ReadFile("testdata/cloudevent_required_only.json") require.NoError(t, err) var ce *CloudEvent diff --git a/sdk/internal/log/log.go b/sdk/internal/log/log.go index 4f1dcf1b78a6..76dadf7d3513 100644 --- a/sdk/internal/log/log.go +++ b/sdk/internal/log/log.go @@ -44,7 +44,7 @@ func Should(cls Event) bool { if log.lst == nil { return false } - if log.cls == nil || len(log.cls) == 0 { + if len(log.cls) == 0 { return true } for _, c := range log.cls { diff --git a/sdk/internal/recording/recording.go b/sdk/internal/recording/recording.go index 32193b04b348..8c9e1f611690 100644 --- a/sdk/internal/recording/recording.go +++ b/sdk/internal/recording/recording.go @@ -144,7 +144,7 @@ func init() { certPool, err = x509.SystemCertPool() if err != nil { log.Println("could not create a system cert pool") - log.Panicf(err.Error()) + log.Panic(err.Error()) } } cert, err := os.ReadFile(localFile) diff --git a/sdk/internal/recording/server.go b/sdk/internal/recording/server.go index 89ad4f4ad5eb..ae7c3dc391cb 100644 --- a/sdk/internal/recording/server.go +++ b/sdk/internal/recording/server.go @@ -12,7 +12,6 @@ import ( "compress/gzip" "fmt" "io" - "io/ioutil" "log" "math/rand" "net/http" @@ -303,11 +302,11 @@ func ensureTestProxyInstalled(proxyVersion string, proxyPath string, proxyDir st } func getProxyLog() (*os.File, error) { - rand.Seed(time.Now().UnixNano()) + rng := rand.New(rand.NewSource(time.Now().UnixNano())) const letters = "abcdefghijklmnopqrstuvwxyz" suffix := make([]byte, 6) for i := range suffix { - suffix[i] = letters[rand.Intn(len(letters))] + suffix[i] = letters[rng.Intn(len(letters))] } proxyLogName := fmt.Sprintf("test-proxy.log.%s", suffix) proxyLog, err := os.Create(filepath.Join(os.TempDir(), proxyLogName)) @@ -322,14 +321,14 @@ func getProxyVersion(gitRoot string) (string, error) { overrideProxyVersionConfig := filepath.Join(gitRoot, "eng/target_proxy_version.txt") if _, err := os.Stat(overrideProxyVersionConfig); err == nil { - version, err := ioutil.ReadFile(overrideProxyVersionConfig) + version, err := os.ReadFile(overrideProxyVersionConfig) if err == nil { proxyVersion := strings.TrimSpace(string(version)) return proxyVersion, nil } } - version, err := ioutil.ReadFile(proxyVersionConfig) + version, err := os.ReadFile(proxyVersionConfig) if err != nil { return "", err }