Closed
Description
Go version
go version devel go1.22-d73b4322ed Thu Dec 14 22:24:40 2023 +0000 linux/amd64
What operating system and processor architecture are you using (go env
)?
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/mvdan/.cache/go-build'
GOENV='/home/mvdan/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/mvdan/go/pkg/mod'
GONOPROXY='github.com/cue-unity'
GONOSUMDB='github.com/cue-unity'
GOOS='linux'
GOPATH='/home/mvdan/go'
GOPRIVATE='github.com/cue-unity'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/mvdan/tip'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/mvdan/tip/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='devel go1.22-d73b4322ed Thu Dec 14 22:24:40 2023 +0000'
GCCGO='gccgo'
GOAMD64='v3'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2866565515=/tmp/go-build -gno-record-gcc-switches'
What did you do?
$ go version
go version devel go1.22-d73b4322ed Thu Dec 14 22:24:40 2023 +0000 linux/amd64
$ go run cuelang.org/go/cmd/cue@v0.5.0-beta.5 import -p json
go: -p must be a positive integer: 0
$ /usr/bin/go version
go version go1.21.5 linux/amd64
$ /usr/bin/go run cuelang.org/go/cmd/cue@v0.5.0-beta.5 import -p json
$
What did you expect to see?
Same behavior between Go tip and 1.21; the flag should be passed to the cue
program without any error from cmd/go.
What did you see instead?
It seems like cmd/go tries to parse the -p json
flag, perhaps not realizing that go run
takes an arbitrary number of flags and arguments to pass on to the main package being run:
$ go run -h
usage: go run [build flags] [-exec xprog] package [arguments...]
In my case, import -p json
go after the single package argument, so cmd/go should not attempt to parse them.
cc @bcmills I suspect this might be a very recent regression due to https://go-review.googlesource.com/c/go/+/546635. I haven't bisected, but I've also never run into this error before.
Metadata
Metadata
Labels
Type
Projects
Status
Done