Open
Description
What version of Go are you using (go version
)?
$ go version go version go1.16.4 linux/amd64
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="/home/manlio/.local/bin" GOCACHE="/home/manlio/.cache/go-build" GOENV="/home/manlio/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="*.local" GOMODCACHE="/home/manlio/.local/lib/go/pkg/mod" GONOPROXY="" GONOSUMDB="*.local" GOOS="linux" GOPATH="/home/manlio/.local/lib/go:/home/manlio/src/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/lib/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="go1.16.4" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/dev/null" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1005692883=/tmp/go-build -gno-record-gcc-switches" GOROOT/bin/go version: go version go1.16.4 linux/amd64 GOROOT/bin/go tool compile -V: compile version go1.16.4 uname -sr: Linux 5.12.7-arch1-1 /usr/lib/libc.so.6: GNU C Library (GNU libc) release release version 2.33. gdb --version: GNU gdb (GDB) 10.2
What did you do?
The packages
help topic (go help packages
or https://golang.org/pkg/cmd/go/#hdr-Package_lists_and_patterns), says:
As a special case, if the package list is a list of .go files from a
single directory, the command is applied to a single synthesized
package made up of exactly those files, ignoring any build constraints
in those files and ignoring any other files in the directory.
The following command, as an example, works
go build /abs/path/to/file.go
The problem is that, in module mode, a package must belong to a module, so in theory go build
should fail as in
cd /abs/path/to
go build
go: go.mod file not found in current directory or any parent directory; see 'go help modules'
The documentation should say that a module is also synthesized.