What version of Go are you using (go version)?
go version go1.18 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
go env Output
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/matthewboyle/Library/Caches/go-build"
GOENV="/Users/matthewboyle/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/matthewboyle/go/pkg/mod"
GONOPROXY="github.com/moonr-app"
GONOSUMDB="github.com/moonr-app"
GOOS="darwin"
GOPATH="/Users/matthewboyle/go"
GOPRIVATE="github.com/moonr-app"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/matthewboyle/go/go1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/matthewboyle/go/go1.18/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/matthewboyle/Dev/moonr/test1.18/go.mod"
GOWORK="/Users/matthewboyle/Dev/moonr/test1.18/go.work"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6c/565l_36j5f93vczwq09z9_100000gn/T/go-build836227308=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
I am trying to test go workspaces. I have created a really simple project with the following file tree:

go.mod looks as follows:
module test1.18
go 1.18
require golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
go.work:
and main.go
package main
import (
"log"
"golang.org/x/sync/errgroup"
)
func main() {
var eg errgroup.Group
eg.Go(func() error {
log.Println("did a thing")
return nil
})
if err := eg.Wait(); err != nil {
log.Println("err")
}
}
What did you expect to see?
I run go run ./workspace/main.go and it works great. It uses workspace mode and replaces the sync module. However, I am trying to run go run -workfile=off ./workspace/main.go and I get the following error:
flag provided but not defined: -workfile
What did you see instead?
I would expect my program to run without using my go.work file.
I got round this by running the following instead:
GOWORK=off go run ./workspace/main.go
which worked correctly.
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
I am trying to test go workspaces. I have created a really simple project with the following file tree:

go.mod looks as follows:
go.work:
and main.go
What did you expect to see?
I run
go run ./workspace/main.goand it works great. It uses workspace mode and replaces the sync module. However, I am trying to rungo run -workfile=off ./workspace/main.goand I get the following error:What did you see instead?
I would expect my program to run without using my go.work file.
I got round this by running the following instead:
which worked correctly.