Skip to content

Option to customize go:generate line #15

Description

@termermc

Is your feature request related to a problem? Please describe.

When using a Go workspace, the default go:generate line used in wire_gen.go fails:

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.
wire_gen.go:3: running "go": exit status 1

I'm using the Go 1.24 tool system to install Wire. This is preferable to installing it globally, since the version is tied to the project and doesn't force developers to install global tools that might have conflicting versions.

Calling wire with go tool wire works in workspaces, whereas the default go:generate line does not.

Describe the solution you'd like

If I had the ability to change the command in wire_gen.go's go:generate line, I could use go tool wire, which would use the Wire version owned by the Go project. This would solve my issue with workspaces.

Describe alternatives you've considered

The workaround I'm doing right now is just calling Wire manually with go tool. I would prefer to use go generate though, since other parts of the project use it.

Additional context

It may be worth transitioning this Wire fork to using go tool by default, since it's the preferred way of managing project tools from Go 1.24 onward.

I would be willing to contribute the necessary changes to this project and documentation if needed.

I would also like to thank the authors of this project for continuing to maintain Wire. I really like the speed improvements it has brought.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions