Skip to content
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

go generate ./... no longer works with go 1.22.0 and wire 0.6.0 #403

Open
scr-oath opened this issue Feb 9, 2024 · 3 comments
Open

go generate ./... no longer works with go 1.22.0 and wire 0.6.0 #403

scr-oath opened this issue Feb 9, 2024 · 3 comments

Comments

@scr-oath
Copy link

scr-oath commented Feb 9, 2024

Describe the bug

wire ./... seems to work fine, but go generate ./... now fails due to the use of go run with -mod=mod

go version
go version go1.22.0 darwin/arm64

grep wire go.mod 
        github.com/google/wire v0.6.0

To Reproduce

Create a wired module and try to run generate to re-wire it.

go generate ./...
# ...
go: -mod may only be set to readonly or vendor when in workspace mode, but it is set to "mod"
        Remove the -mod flag to use the default readonly value, 
        or set GOWORK=off to disable workspace mode.

Expected behavior

go generate should work just as well as wire - the generated //go:generate line should not be so different that it cannot run.

Version

0.6.0

Additional context

Add any other context about the problem here.

@alexus1024
Copy link

Have the same issue for
go version go1.21.6 darwin/arm64 and the latest wire v0.6.0
My project uses go workspaces (there is go.work file in the root). This is the main reason for the issue, probably.

It is fixable by removing "-mod=mod" from the generated wire_gen.go file. But it returns after the next code generation.

Here is the problematic line: https://github.com/google/wire/blame/e57deea2f8bbe2386b756f2555e02de33e20a3f0/internal/wire/wire.go#L270
PR: #353

It makes wire not fully compatible with go workspaces

@alexus1024
Copy link

One solution that would work for me:
When the wire gen -header_file flag is specified, do not output the first 3 lines in a generated file ("DO NOT EDIT" comment, new line, go-generate command).

@Dokiys
Copy link

Dokiys commented Mar 7, 2024

I meet the same problem. In my case -mod=mod can not work in go workspace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants