From 5a5ca29f200ad0fa62e8d98df929f96f82fbcaa2 Mon Sep 17 00:00:00 2001 From: Alexey Palazhchenko Date: Wed, 6 Mar 2024 14:19:39 +0400 Subject: [PATCH] Use Go 1.22.1 (#4155) --- build/docker/all-in-one.Dockerfile | 4 +-- build/docker/development.Dockerfile | 6 ++-- build/docker/production.Dockerfile | 4 +-- go.mod | 2 ++ integration/go.mod | 2 ++ tools/check.go | 56 ----------------------------- tools/go.mod | 2 ++ tools/golangci/go.mod | 2 ++ tools/old.go | 25 ------------- tools/tools.go | 12 ------- 10 files changed, 15 insertions(+), 100 deletions(-) delete mode 100644 tools/check.go delete mode 100644 tools/old.go diff --git a/build/docker/all-in-one.Dockerfile b/build/docker/all-in-one.Dockerfile index 09db2d6fce46..719936b14a70 100644 --- a/build/docker/all-in-one.Dockerfile +++ b/build/docker/all-in-one.Dockerfile @@ -14,7 +14,7 @@ ARG LABEL_COMMIT # prepare stage -FROM --platform=$BUILDPLATFORM golang:1.22.0 AS all-in-one-prepare +FROM --platform=$BUILDPLATFORM golang:1.22.1 AS all-in-one-prepare # use a single directory for all Go caches to simpliy RUN --mount commands below ENV GOPATH /cache/gopath @@ -38,7 +38,7 @@ EOF # build stage -FROM golang:1.22.0 AS all-in-one-build +FROM golang:1.22.1 AS all-in-one-build ARG TARGETARCH diff --git a/build/docker/development.Dockerfile b/build/docker/development.Dockerfile index 63d2de435a31..39f487096386 100644 --- a/build/docker/development.Dockerfile +++ b/build/docker/development.Dockerfile @@ -12,7 +12,7 @@ ARG LABEL_COMMIT # prepare stage -FROM --platform=$BUILDPLATFORM golang:1.22.0 AS development-prepare +FROM --platform=$BUILDPLATFORM golang:1.22.1 AS development-prepare # use a single directory for all Go caches to simpliy RUN --mount commands below ENV GOPATH /cache/gopath @@ -36,7 +36,7 @@ EOF # build stage -FROM golang:1.22.0 AS development-build +FROM golang:1.22.1 AS development-build ARG TARGETARCH ARG TARGETVARIANT @@ -107,7 +107,7 @@ COPY --from=development-build /src/bin/ferretdb /ferretdb # final stage -FROM golang:1.22.0 AS development +FROM golang:1.22.1 AS development ENV GOCOVERDIR=/tmp/cover ENV GORACE=halt_on_error=1,history_size=2 diff --git a/build/docker/production.Dockerfile b/build/docker/production.Dockerfile index 0188696f4d1e..1f592337ab7c 100644 --- a/build/docker/production.Dockerfile +++ b/build/docker/production.Dockerfile @@ -12,7 +12,7 @@ ARG LABEL_COMMIT # prepare stage -FROM --platform=$BUILDPLATFORM golang:1.22.0 AS production-prepare +FROM --platform=$BUILDPLATFORM golang:1.22.1 AS production-prepare # use a single directory for all Go caches to simpliy RUN --mount commands below ENV GOPATH /cache/gopath @@ -36,7 +36,7 @@ EOF # build stage -FROM golang:1.22.0 AS production-build +FROM golang:1.22.1 AS production-build ARG TARGETARCH ARG TARGETVARIANT diff --git a/go.mod b/go.mod index 7549b3ca9182..dfd393d2557a 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,8 @@ module github.com/FerretDB/FerretDB go 1.22 +toolchain go1.22.1 + require ( github.com/AlekSi/pointer v1.2.0 github.com/SAP/go-hdb v1.8.5 diff --git a/integration/go.mod b/integration/go.mod index df2b384174fc..dcb4b78950ab 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -2,6 +2,8 @@ module github.com/FerretDB/FerretDB/integration go 1.22 +toolchain go1.22.1 + replace github.com/FerretDB/FerretDB => ../ require ( diff --git a/tools/check.go b/tools/check.go deleted file mode 100644 index cd725fc63950..000000000000 --- a/tools/check.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2021 FerretDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// This file is invoked from tools.go or old.go and should work with any version of Go. -// Keep both old and new styles of build tags. - -//go:build ignore -// +build ignore - -package main - -import ( - "flag" - "log" - "regexp" - "runtime" - "strconv" -) - -func main() { - log.SetFlags(0) - - oldF := flag.Bool("old", false, "") - flag.Parse() - - if *oldF { - log.Fatalf("FerretDB requires Go 1.22 or later.") - } - - v := runtime.Version() - re := regexp.MustCompile(`go1\.(\d+)`) - m := re.FindStringSubmatch(v) - if len(m) != 2 { - log.Fatalf("Unexpected version %q.", v) - } - - minor, err := strconv.Atoi(m[1]) - if err != nil { - log.Fatalf("Unexpected version %q: %s.", v, err) - } - - if minor < 18 { - log.Fatalf("FerretDB requires Go 1.22 or later. The version of `go` binary in $PATH is %q.", v) - } -} diff --git a/tools/go.mod b/tools/go.mod index 6034a004424a..9ea80bf51ffe 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -2,6 +2,8 @@ module github.com/FerretDB/FerretDB/tools go 1.22 +toolchain go1.22.1 + require ( github.com/FerretDB/gh v0.1.3 github.com/go-task/task/v3 v3.34.1 diff --git a/tools/golangci/go.mod b/tools/golangci/go.mod index 5f2277c60265..8a0dcab50ded 100644 --- a/tools/golangci/go.mod +++ b/tools/golangci/go.mod @@ -4,6 +4,8 @@ module github.com/FerretDB/FerretDB/tools/golangci go 1.22 +toolchain go1.22.1 + require github.com/golangci/golangci-lint v1.56.2 require ( diff --git a/tools/old.go b/tools/old.go deleted file mode 100644 index 06449a11a206..000000000000 --- a/tools/old.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2021 FerretDB Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Keep both old and new styles of build tags. - -//go:build !go1.22 -// +build !go1.22 - -package tools - -// The version of Go used in `go generate` command is old - we know that from the build tags above. -// Let the user know. - -//go:generate go run check.go -old diff --git a/tools/tools.go b/tools/tools.go index 8e9dcb277a0a..75bde3e7c5b9 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -12,11 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -// Keep both old and new styles of build tags. - -//go:build go1.22 -// +build go1.22 - package tools import ( @@ -32,13 +27,6 @@ import ( _ "mvdan.cc/gofumpt" ) -// Check that `go` in $PATH have the right version. -// Catches problems like `/some/path/go generate` invocations where `/some/path/go` is 1.22+ -// (that's checked by the build tags above), but just `go` in $PATH (typically something like `/usr/bin/go`) -// is an earlier version. - -//go:generate go run check.go - //go:generate go build -v -o ../bin/ ./checkdocs //go:generate go build -v -o ../bin/ ./checkswitch //go:generate go build -v -o ../bin/ ./checkcomments