golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.55k stars 17.61k forks source link

result of go mod tidy has errors,but go build not #48378

Closed polatouche6 closed 3 years ago

polatouche6 commented 3 years ago

What version of Go are you using (go version)?

$ go version
go version go1.14.7 windows/amd64

Does this issue reproduce with the latest release?

no

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\tdl\AppData\Local\go-build
set GOENV=C:\data\moved_software\golang\env
set GOEXE=.exe
set GOFLAGS=-mod=mod
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOOS=windows
set GOPATH=C:\data\tdl\share_data\godata
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\data\moved_software\golang
set GOSUMDB=off
set GOTMPDIR=
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\tdl\AppData\Local\Temp\go-build965195838=/tmp/go-build -gno-record-gcc-switches

What did you do?

i run with go build, that has no errors, but i run with go mod tidy, it is wrong

$ go mod tidy
sso-safety-count/src/common imports
        github.com/spf13/viper imports
        github.com/spf13/afero imports
        io/fs: package io/fs is not in GOROOT (C:\data\moved_software\golang\src\io\fs)
go-project/src/common imports
        github.com/spf13/viper imports
        github.com/spf13/afero tested by
        github.com/spf13/afero.test imports
        testing/fstest: package testing/fstest is not in GOROOT (C:\data\moved_software\golang\src\testing\fstest)

i found go build will build with discriminating go version, but go mod tidy not

What did you expect to see?

go mod tidy will run with discriminating go version

What did you see instead?

tdl@DESKTOP-HA3BA9Q MINGW64 go-project(master)
$ go mod tidy
tdl@DESKTOP-HA3BA9Q MINGW64 go-project(master)
seankhliao commented 3 years ago

This is fixed in later versions and 1.14 is no longer supported