go version)?$ go version go version go1.14.4 windows/amd64
Yes
go env)?go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\karlAppData\Local\go-build
set GOENV=C:\Users\karlAppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\karl\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkgtoolwindows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\karl\codewinsrv\go.mod
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\karlAppData\Local\Temp\go-build530336870=/tmp/go-build -gno-record-gcc-switches
main.go:
package main
func main() {
}
go.mod:
module mymod
go 1.13
require golang.org/x/sys v0.0.0-20190204203706-41f3e6584952
go build
I expected it to download that version of sys.
go: finding module for package golang.org/x/sys
main.go:4:2: module golang.org/x/sys@latest found (v0.0.0-20200610111108-226ff32320da), but does not contain package golang.org/x/sys
I wanted version 20190204203706-41f3e6584952 but it's attempting to download 20200610111108-226ff32320da instead, and also failing for some reason.
What did you do?
Please post the actual program that reproduces the problem. This one does not — the main.go file seems to have been oversimplified.
mymod$ txtar * </dev/null
-- go.mod --
module mymod
go 1.13
require golang.org/x/sys v0.0.0-20190204203706-41f3e6584952
-- main.go --
package main
func main() {
}
mymod$ go build
mymod$ cat go.mod
module mymod
go 1.13
require golang.org/x/sys v0.0.0-20190204203706-41f3e6584952
From the error message you are reporting, I suspect that your actual program includes the line
import (
"golang.org/x/sys"
)
which provokes go build to attempt to find some version of a module containing the _package_ golang.org/x/sys. The module golang.org/x/sys does not have any .go source files at its root, so there is no such package (as the error message states).
Ah I see, the error message isn't very clear about this. It just says "does not contain package XYZ", not "There are no go files at this level".
CC @jayconrod @matloob
I'm not sure how we could make this clearer without also making it too verbose, but if you have a specific suggestion we could consider it.
Maybe keep the current error msg, plus append "No go files found. Are you sure you have the correct import path?"
+1
Most helpful comment
Maybe keep the current error msg, plus append "No go files found. Are you sure you have the correct import path?"