golang/go

cmd/go: reject 'go generate' on packages in unreplaced module dependencies?

Open

#29,751 opened on 2019年1月15日

GitHub で見る
 (5 comments) (1 reaction) (0 assignees)Go (19,008 forks)batch import
GoCommandNeedsFixhelp wantedmodules

Repository metrics

Stars
 (133,883 stars)
PR merge metrics
 (30d に merged PR はありません)

説明

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

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)?

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.

コントリビューターガイド