New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: attempt to generate in dependency modules should fail #29751

Open
myitcv opened this Issue Jan 15, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@myitcv
Copy link
Member

myitcv commented Jan 15, 2019

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

$ go version
go version go1.12beta2 linux/amd64

Does this issue reproduce with the latest release?

Testing with the beta pre the 1.12 release.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPROXY=""
GORACE=""
GOROOT="/home/myitcv/gos"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build968143131=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Ran testscript on the following:

go generate fruit.com/fruit

-- go.mod --
module mod

require fruit.com v1.0.0

-- main.go --
package main

func main() {
}

-- .gomodproxy/fruit.com_v1.0.0/.mod --
module fruit.com

-- .gomodproxy/fruit.com_v1.0.0/.info --
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}

-- .gomodproxy/fruit.com_v1.0.0/go.mod --
module fruit.com

-- .gomodproxy/fruit.com_v1.0.0/fruit/fruit.go --
package fruit

//go:generate bash -c "echo 'package fruit' > something.go"

What did you expect to see?

A failed run.

What did you see instead?

> go generate fruit.com/fruit
[stderr]
go: finding fruit.com v1.0.0
go: downloading fruit.com v1.0.0
go: extracting fruit.com v1.0.0
go: not generating in packages in dependency modules

PASS

It feels like this should be an error instead of a noisy success. Reason being, I've specified the pattern of a non-main module package(s) on the command line; based on the current implementation, that will never succeed (even if there is a replace directive).

cc @bcmills.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment