Skip to content

Commit

Permalink
Update remaining usages of Go 1.21 to 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
fasmat committed Jan 7, 2025
1 parent bbb17a9 commit 3576af8
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG VARIANT="1-1.21-bullseye"
ARG VARIANT="1-1.22-bullseye"
FROM mcr.microsoft.com/devcontainers/go:${VARIANT}

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
"name": "Go 1.21.0",
"name": "Go 1.22.0",
"build": {
"dockerfile": "Dockerfile"
},
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/vet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ jobs:
with:
go-version: '1.22.x'
- name: Install tools
# go: golang.org/x/tools/cmd/goimports@latest: golang.org/x/[email protected] requires go >= 1.22.0
run: |
go install golang.org/x/lint/golint@latest && \
go install golang.org/x/tools/cmd/goimports@v0.24.0 && \
go install honnef.co/go/tools/cmd/staticcheck@v0.4.7
go install golang.org/x/tools/cmd/goimports@v0.29.0 && \
go install honnef.co/go/tools/cmd/staticcheck@v0.5.1
- name: Execute vet.sh
run: ./.github/workflows/vet.sh
2 changes: 1 addition & 1 deletion internal/postprocessor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.21 as builder
FROM golang:1.22 as builder

# Copy local code to the container image.
COPY . /postprocessor/
Expand Down
2 changes: 1 addition & 1 deletion internal/postprocessor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const (
// This is the default Go version that will be generated into new go.mod
// files. It should be updated every time we drop support for old Go
// versions.
defaultGoModuleVersion = "1.21"
defaultGoModuleVersion = "1.22"
)

var (
Expand Down
4 changes: 2 additions & 2 deletions profiler/kokoro/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export GOOGLE_APPLICATION_CREDENTIALS="${KOKORO_KEYSTORE_DIR}/72935_cloud-profil
export GCLOUD_TESTS_GOLANG_PROJECT_ID="cloud-profiler-e2e"

# Ensure a newer version of Go is used so it is compatible with newer libraries.
# Here we install v1.21.3 which is the current version as of October 2023.
GOVERSION="1.21.3"
# Here we install v1.22.10 which is the current version as of January 2025.
GOVERSION="1.22.10"
retry curl -LO https://go.dev/dl/go${GOVERSION}.linux-amd64.tar.gz
sudo rm -rf /usr/local/go && tar -C /usr/local -xzf go${GOVERSION}.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
Expand Down
7 changes: 2 additions & 5 deletions storage/internal/benchmarks/continuous_reads.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"math/rand"
"os"
"path"
"sort"
"slices"
"sync"
"time"

Expand Down Expand Up @@ -183,10 +183,7 @@ func (r *continuousReads) run(ctx context.Context) error {
}

func (r *continuousReads) compileResults() {
// TO-DO: switch to slices.Sort(r.results) when Go<1.21 support is dropped
sort.Slice(r.results, func(i, j int) bool {
return r.results[i] < r.results[j]
})
slices.Sort(r.results)
l := len(r.results)

percentiles := map[string]time.Duration{
Expand Down
8 changes: 0 additions & 8 deletions storage/transfermanager/downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,14 +815,6 @@ type DownloadOutput struct {
crc32c uint32
}

// TODO: use built-in after go < 1.21 is dropped.
func min(a, b int64) int64 {
if a < b {
return a
}
return b
}

// numShards calculates how many shards the given range should be divided into
// given the part size.
func numShards(attrs *storage.ReaderObjectAttrs, r *DownloadRange, partSize int64) int {
Expand Down

0 comments on commit 3576af8

Please sign in to comment.