运行时更新的 mod 文件
原标题:go.mod file getting updated when running go mod tidy
I have the following go.mod file. I m unable to run the module as the compiler in VSCode asks me to run go mod tidy. When I run go mod tidy my go.mod file gets updated with go version getting bumped from 1.19 to 1.21, and a new toolchain go1.22.1 line added. go.sum file is also getting updated.
This behaviour is only happening for me and not for my colleagues (for the exactly same go.mod file), indicating that something is wrong with my setup.
Running go mod tidy -go=1.19 gives the following error -- go: google.golang.org/grpc@v1.65.0 requires go@1.21, but 1.19 is requested
I am confused so as to why this is happening, and what can I do to stop this behaviour
go.mod file :
module product-api
go 1.19
require (
cloud.google.com/go/pubsub v1.37.0
github.com/DataDog/datadog-go/v5 v5.2.0
github.com/fermatcommerce/fermat/go/common v0.0.0-20220906110310-ef66faa0b8db
github.com/fermatcommerce/fermat/go/product-svc v0.0.0-00010101000000-000000000000
github.com/fermatcommerce/fermat/proto/product-service/go v0.0.0-00010101000000-000000000000
github.com/go-chi/chi/v5 v5.0.8
github.com/go-chi/cors v1.2.1
github.com/google/uuid v1.6.0
github.com/lib/pq v1.10.6
github.com/shopspring/decimal v1.3.1
github.com/stretchr/testify v1.8.4
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8
google.golang.org/protobuf v1.34.2
)
require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/cloudsqlconn v0.5.1 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/hcsshim v0.9.4 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/containerd/containerd v1.6.8 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.17+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.2 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx/v4 v4.17.0 // indirect
github.com/jackc/pgx/v5 v5.5.2 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/moby/sys/mount v0.3.3 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect
github.com/opencontainers/runc v1.1.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/testcontainers/testcontainers-go v0.15.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.169.0 // indirect
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240528184218-531527333157 // indirect
google.golang.org/grpc v1.65.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
go env returns the following
GO111MODULE=
GOARCH= arm64
GOBIN=
GOCACHE= /Users/tanmay/Library/Caches/go-build
GOENV= /Users/tanmay/Library/Application Support/go/env
GOEXE=
GOEXPERIMENT=
GOFLAGS=
GOHOSTARCH= arm64
GOHOSTOS= darwin
GOINSECURE=
GOMODCACHE= /Users/tanmay/go/pkg/mod
GONOPROXY=
GONOSUMDB=
GOOS= darwin
GOPATH= /Users/tanmay/go
GOPRIVATE=
GOPROXY= https://proxy.golang.org,direct
GOROOT= /opt/homebrew/Cellar/go/1.22.1/libexec
GOSUMDB= sum.golang.org
GOTMPDIR=
GOTOOLCHAIN= local
GOTOOLDIR= /opt/homebrew/Cellar/go/1.22.1/libexec/pkg/tool/darwin_arm64
GOVCS=
GOVERSION= go1.22.1
GCCGO= gccgo
AR= ar
CC= cc
CXX= c++
CGO_ENABLED= 1
GOMOD= /Users/tanmay/Desktop/fermat/go/product-api/go.mod
GOWORK=
CGO_CFLAGS= -O2 -g
CGO_CPPFLAGS=
CGO_CXXFLAGS= -O2 -g
CGO_FFLAGS= -O2 -g
CGO_LDFLAGS= -O2 -g
PKG_CONFIG= pkg-config
GOGCCFLAGS= -fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/tk/g6yl6ybj5gz764nfsh8zrfh00000gn/T/go-build2365762375=/tmp/go-build -gno-record-gcc-switches -fno-common
问题回答
Running go mod tidy -go=1.19 gives the following error -- go: google.golang.org/grpc@v1.65.0 requires go@1.21, but 1.19 is requested
This seems to be self explanatory: You ll need at least Go 1.21 for google.golang.org/grpc 1.65.0. Upgrade your required Go version to at least 1.21 or downgrade the package, 1.64.1 is the last version compatible with Go 1.19. See also the release notes and Issue 7250
This behaviour is only happening for me and not for my colleagues (for the exactly same go.mod file), indicating that something is wrong with my setup.
This change was introduced with go 1.21:
The go line must be greater than or equal to the go line of all dependencies.
So your colleagues are using an older version of Go.
I am confused so as to why this is happening, and what can I do to stop this behaviour
Update all you Go compilers to the latest version:
Each major Go release is supported until there are two newer major releases.
So while Go 1.20 is technically still supported, Go 1.23 is expected to be released in August 2024 and support will be dropped.
相关问题
Connecting Actionscript 3.0 with a C++ backend?
I am curious to know if there is a way of connecting a flash front-end to a C++ driven backend? I m not currently working on a project that involves this, but I found out about an application used in ...
Formats for communicating between backend and Objective-C/Cocoa
I m developing an iPhone app that is connected to a backend server. It needs to communicate with it many times, through several requests. I m sending HTTP messages, but I want to receive more complex ...
Different authentication backend for the django admin
What would be the best solution to use a different authentication backend for the Django admin site?
Django - update a model won t delete the old FileField
I am implementing an application with django, which has a model with a FileField:
class Slideshow(models.Model):
name = models.CharField(max_length=30,unique=True)
thumbnail = models....
Is it possible to use the Google App Engine as a backend database for Android applications?
I would like to write a client application for Android that uses the Google App Engine as a database backend. My Android client would connect to the App Engine to save information, then it would ...
MS Access 2003 - Really simple query
If I try to duplicate an access file (this file is split into mdb and be mdb, and also has mde files), by importing everything into a brand new access application, why won t the table links work? ...
Building a website backend in c#, compiled to a binary
I am creating a novel website that integrates web feeds from around the internet. I want to build a backend that does CPU intensive analysis of the web data on a regular basis, which will eventually ...
Need a cool hotkey for my hidden website-login
I am developing a CMS. One of the greatest everyday annoyances when working with it is that when you are on a front-end page, not logged in, and want to make a change, you need to go to the back-end ...