Repository: google/wire
Pull request #353 (2022-03-30 12:59:11)

fix: run wire with -mod=mod
fixed the issue when using wire with Go module.
```
go run github.com/google/wire/cmd/wire gen
/go/pkg/mod/github.com/google/wire@v0.5.0/cmd/wire/main.go:34:2: missing go.sum entry for module providing package github.com/google/subcommands (imported by github.com/google/wire/cmd/wire); to add:
        go get github.com/google/wire/cmd/wire@v0.5.0
```

Close: https://github.com/google/wire/issues/299, https://github.com/google/wire/pull/342

eliben: We're quite busy right now and working to figure out who the right person to review this would be. Please respect that this is an open source project that's offered to the community for free and in good will.

Thanks for the understanding
giautm: Thank you for your response, I understand what you mean.

This is my first time contributing to this project, so just wanted to get some attention from the team for the review.

Again, thank you very much. I will wait patiently for a response. Have a nice day!
giautm: Hello @vangent. sorry to bother you, but can you help me review this PR? 
giautm: hello @eliben, can you merge and release this PR please?
eliben: The folks I've CCd on this issue in a previous comment all volunteered to maintain wire and are able to merge PRs.
jayzhuang: Hey @eliben, I think I only have triage rights, not write access, so I can't merge PRs.

Patch:
diff --git a/_tutorial/wire_gen.go b/_tutorial/wire_gen.go
index 7a93a7b..fe54ab7 100644
--- a/_tutorial/wire_gen.go
+++ b/_tutorial/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/docs/guide.md b/docs/guide.md
index dc1b42e..530650a 100644
--- a/docs/guide.md
+++ b/docs/guide.md
@@ -151,7 +151,7 @@ Wire will produce an implementation of the injector in a file called
 ```go
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //+build !wireinject
 
 package main
diff --git a/internal/wire/wire.go b/internal/wire/wire.go
index a9b7a50..5cedeb1 100644
--- a/internal/wire/wire.go
+++ b/internal/wire/wire.go
@@ -267,7 +267,7 @@ func (g *gen) frame(tags string) []byte {
 		tags = fmt.Sprintf(" gen -tags \"%s\"", tags)
 	}
 	buf.WriteString("// Code generated by Wire. DO NOT EDIT.\n\n")
-	buf.WriteString("//go:generate go run github.com/google/wire/cmd/wire" + tags + "\n")
+	buf.WriteString("//go:generate go run -mod=mod github.com/google/wire/cmd/wire" + tags + "\n")
 	buf.WriteString("//+build !wireinject\n\n")
 	buf.WriteString("package ")
 	buf.WriteString(g.pkg.Name)


Test patch:
diff --git a/internal/wire/testdata/BindInjectorArg/want/wire_gen.go b/internal/wire/testdata/BindInjectorArg/want/wire_gen.go
index 25ce723..5f5b210 100644
--- a/internal/wire/testdata/BindInjectorArg/want/wire_gen.go
+++ b/internal/wire/testdata/BindInjectorArg/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/BindInjectorArgPointer/want/wire_gen.go b/internal/wire/testdata/BindInjectorArgPointer/want/wire_gen.go
index 20a9f53..15d6f0e 100644
--- a/internal/wire/testdata/BindInjectorArgPointer/want/wire_gen.go
+++ b/internal/wire/testdata/BindInjectorArgPointer/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/BindInterfaceWithValue/want/wire_gen.go b/internal/wire/testdata/BindInterfaceWithValue/want/wire_gen.go
index b6255e1..58d82bf 100644
--- a/internal/wire/testdata/BindInterfaceWithValue/want/wire_gen.go
+++ b/internal/wire/testdata/BindInterfaceWithValue/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/BuildTagsAllPackages/want/wire_gen.go b/internal/wire/testdata/BuildTagsAllPackages/want/wire_gen.go
index f75adb5..16c0df2 100644
--- a/internal/wire/testdata/BuildTagsAllPackages/want/wire_gen.go
+++ b/internal/wire/testdata/BuildTagsAllPackages/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/Chain/want/wire_gen.go b/internal/wire/testdata/Chain/want/wire_gen.go
index 257e642..cf9e9ee 100644
--- a/internal/wire/testdata/Chain/want/wire_gen.go
+++ b/internal/wire/testdata/Chain/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/Cleanup/want/wire_gen.go b/internal/wire/testdata/Cleanup/want/wire_gen.go
index eea8b22..1519c10 100644
--- a/internal/wire/testdata/Cleanup/want/wire_gen.go
+++ b/internal/wire/testdata/Cleanup/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/CopyOtherDecls/want/wire_gen.go b/internal/wire/testdata/CopyOtherDecls/want/wire_gen.go
index 3dcb4b5..c654540 100644
--- a/internal/wire/testdata/CopyOtherDecls/want/wire_gen.go
+++ b/internal/wire/testdata/CopyOtherDecls/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/DocComment/want/wire_gen.go b/internal/wire/testdata/DocComment/want/wire_gen.go
index a1027b9..3efb22a 100644
--- a/internal/wire/testdata/DocComment/want/wire_gen.go
+++ b/internal/wire/testdata/DocComment/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ExampleWithMocks/want/wire_gen.go b/internal/wire/testdata/ExampleWithMocks/want/wire_gen.go
index 9f2fd0f..9cb7b01 100644
--- a/internal/wire/testdata/ExampleWithMocks/want/wire_gen.go
+++ b/internal/wire/testdata/ExampleWithMocks/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ExportedValue/want/wire_gen.go b/internal/wire/testdata/ExportedValue/want/wire_gen.go
index d3ba454..7563ca2 100644
--- a/internal/wire/testdata/ExportedValue/want/wire_gen.go
+++ b/internal/wire/testdata/ExportedValue/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ExportedValueDifferentPackage/want/wire_gen.go b/internal/wire/testdata/ExportedValueDifferentPackage/want/wire_gen.go
index d8bdd24..d8c74d4 100644
--- a/internal/wire/testdata/ExportedValueDifferentPackage/want/wire_gen.go
+++ b/internal/wire/testdata/ExportedValueDifferentPackage/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/FieldsOfImportedStruct/want/wire_gen.go b/internal/wire/testdata/FieldsOfImportedStruct/want/wire_gen.go
index fbdc062..8467ee3 100644
--- a/internal/wire/testdata/FieldsOfImportedStruct/want/wire_gen.go
+++ b/internal/wire/testdata/FieldsOfImportedStruct/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/FieldsOfStruct/want/wire_gen.go b/internal/wire/testdata/FieldsOfStruct/want/wire_gen.go
index c27e6d0..5b8ca2f 100644
--- a/internal/wire/testdata/FieldsOfStruct/want/wire_gen.go
+++ b/internal/wire/testdata/FieldsOfStruct/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/FieldsOfStructPointer/want/wire_gen.go b/internal/wire/testdata/FieldsOfStructPointer/want/wire_gen.go
index 6a03e81..c9fe795 100644
--- a/internal/wire/testdata/FieldsOfStructPointer/want/wire_gen.go
+++ b/internal/wire/testdata/FieldsOfStructPointer/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/FieldsOfValueStruct/want/wire_gen.go b/internal/wire/testdata/FieldsOfValueStruct/want/wire_gen.go
index 5b61dfe..793c04d 100644
--- a/internal/wire/testdata/FieldsOfValueStruct/want/wire_gen.go
+++ b/internal/wire/testdata/FieldsOfValueStruct/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/Header/want/wire_gen.go b/internal/wire/testdata/Header/want/wire_gen.go
index 3ab2107..2f8c5c6 100644
--- a/internal/wire/testdata/Header/want/wire_gen.go
+++ b/internal/wire/testdata/Header/want/wire_gen.go
@@ -2,7 +2,7 @@
 //
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go b/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go
index 6a7cd42..b68a1db 100644
--- a/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go
+++ b/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/InjectInput/want/wire_gen.go b/internal/wire/testdata/InjectInput/want/wire_gen.go
index c17559c..9471cf6 100644
--- a/internal/wire/testdata/InjectInput/want/wire_gen.go
+++ b/internal/wire/testdata/InjectInput/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/InjectWithPanic/want/wire_gen.go b/internal/wire/testdata/InjectWithPanic/want/wire_gen.go
index 92cb390..8b124e5 100644
--- a/internal/wire/testdata/InjectWithPanic/want/wire_gen.go
+++ b/internal/wire/testdata/InjectWithPanic/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/InterfaceBinding/want/wire_gen.go b/internal/wire/testdata/InterfaceBinding/want/wire_gen.go
index f1d7f17..2c1a67b 100644
--- a/internal/wire/testdata/InterfaceBinding/want/wire_gen.go
+++ b/internal/wire/testdata/InterfaceBinding/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/InterfaceBindingReuse/want/wire_gen.go b/internal/wire/testdata/InterfaceBindingReuse/want/wire_gen.go
index bff6877..1c43771 100644
--- a/internal/wire/testdata/InterfaceBindingReuse/want/wire_gen.go
+++ b/internal/wire/testdata/InterfaceBindingReuse/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/InterfaceValue/want/wire_gen.go b/internal/wire/testdata/InterfaceValue/want/wire_gen.go
index 0cc1e8c..9868a90 100644
--- a/internal/wire/testdata/InterfaceValue/want/wire_gen.go
+++ b/internal/wire/testdata/InterfaceValue/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/MultipleSimilarPackages/want/wire_gen.go b/internal/wire/testdata/MultipleSimilarPackages/want/wire_gen.go
index a43b6e4..e406820 100644
--- a/internal/wire/testdata/MultipleSimilarPackages/want/wire_gen.go
+++ b/internal/wire/testdata/MultipleSimilarPackages/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/NamingWorstCase/want/wire_gen.go b/internal/wire/testdata/NamingWorstCase/want/wire_gen.go
index 23dd8fa..e32329d 100644
--- a/internal/wire/testdata/NamingWorstCase/want/wire_gen.go
+++ b/internal/wire/testdata/NamingWorstCase/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/NamingWorstCaseAllInOne/want/wire_gen.go b/internal/wire/testdata/NamingWorstCaseAllInOne/want/wire_gen.go
index dac690d..c081520 100644
--- a/internal/wire/testdata/NamingWorstCaseAllInOne/want/wire_gen.go
+++ b/internal/wire/testdata/NamingWorstCaseAllInOne/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/NiladicIdentity/want/wire_gen.go b/internal/wire/testdata/NiladicIdentity/want/wire_gen.go
index 92cb390..8b124e5 100644
--- a/internal/wire/testdata/NiladicIdentity/want/wire_gen.go
+++ b/internal/wire/testdata/NiladicIdentity/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/NiladicValue/want/wire_gen.go b/internal/wire/testdata/NiladicValue/want/wire_gen.go
index f75adb5..16c0df2 100644
--- a/internal/wire/testdata/NiladicValue/want/wire_gen.go
+++ b/internal/wire/testdata/NiladicValue/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/NoInjectParamNames/want/wire_gen.go b/internal/wire/testdata/NoInjectParamNames/want/wire_gen.go
index c943b5c..b8760db 100644
--- a/internal/wire/testdata/NoInjectParamNames/want/wire_gen.go
+++ b/internal/wire/testdata/NoInjectParamNames/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/PartialCleanup/want/wire_gen.go b/internal/wire/testdata/PartialCleanup/want/wire_gen.go
index a3ef6a4..6cf2640 100644
--- a/internal/wire/testdata/PartialCleanup/want/wire_gen.go
+++ b/internal/wire/testdata/PartialCleanup/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/PkgImport/want/wire_gen.go b/internal/wire/testdata/PkgImport/want/wire_gen.go
index 7dbc469..5f3e127 100644
--- a/internal/wire/testdata/PkgImport/want/wire_gen.go
+++ b/internal/wire/testdata/PkgImport/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/RelativePkg/want/wire_gen.go b/internal/wire/testdata/RelativePkg/want/wire_gen.go
index 92cb390..8b124e5 100644
--- a/internal/wire/testdata/RelativePkg/want/wire_gen.go
+++ b/internal/wire/testdata/RelativePkg/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ReservedKeywords/want/wire_gen.go b/internal/wire/testdata/ReservedKeywords/want/wire_gen.go
index a8a6ae7..7ff3110 100644
--- a/internal/wire/testdata/ReservedKeywords/want/wire_gen.go
+++ b/internal/wire/testdata/ReservedKeywords/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ReturnArgumentAsInterface/want/wire_gen.go b/internal/wire/testdata/ReturnArgumentAsInterface/want/wire_gen.go
index 5d73b54..9d1a331 100644
--- a/internal/wire/testdata/ReturnArgumentAsInterface/want/wire_gen.go
+++ b/internal/wire/testdata/ReturnArgumentAsInterface/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ReturnError/want/wire_gen.go b/internal/wire/testdata/ReturnError/want/wire_gen.go
index 6a75977..5d97466 100644
--- a/internal/wire/testdata/ReturnError/want/wire_gen.go
+++ b/internal/wire/testdata/ReturnError/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/Struct/want/wire_gen.go b/internal/wire/testdata/Struct/want/wire_gen.go
index 3529cb2..e4bf0c7 100644
--- a/internal/wire/testdata/Struct/want/wire_gen.go
+++ b/internal/wire/testdata/Struct/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/StructPointer/want/wire_gen.go b/internal/wire/testdata/StructPointer/want/wire_gen.go
index 1fa1bd8..e96e8cd 100644
--- a/internal/wire/testdata/StructPointer/want/wire_gen.go
+++ b/internal/wire/testdata/StructPointer/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/TwoDeps/want/wire_gen.go b/internal/wire/testdata/TwoDeps/want/wire_gen.go
index 29cde76..bfc52d7 100644
--- a/internal/wire/testdata/TwoDeps/want/wire_gen.go
+++ b/internal/wire/testdata/TwoDeps/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ValueChain/want/wire_gen.go b/internal/wire/testdata/ValueChain/want/wire_gen.go
index 9e4a669..da2cccb 100644
--- a/internal/wire/testdata/ValueChain/want/wire_gen.go
+++ b/internal/wire/testdata/ValueChain/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ValueConversion/want/wire_gen.go b/internal/wire/testdata/ValueConversion/want/wire_gen.go
index 9c1c4b6..b663861 100644
--- a/internal/wire/testdata/ValueConversion/want/wire_gen.go
+++ b/internal/wire/testdata/ValueConversion/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/ValueIsStruct/want/wire_gen.go b/internal/wire/testdata/ValueIsStruct/want/wire_gen.go
index 9e0b96c..f41ed12 100644
--- a/internal/wire/testdata/ValueIsStruct/want/wire_gen.go
+++ b/internal/wire/testdata/ValueIsStruct/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/VarValue/want/wire_gen.go b/internal/wire/testdata/VarValue/want/wire_gen.go
index 8a2bc61..07e4f01 100644
--- a/internal/wire/testdata/VarValue/want/wire_gen.go
+++ b/internal/wire/testdata/VarValue/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject
 
diff --git a/internal/wire/testdata/Varargs/want/wire_gen.go b/internal/wire/testdata/Varargs/want/wire_gen.go
index d6cef6a..703a549 100644
--- a/internal/wire/testdata/Varargs/want/wire_gen.go
+++ b/internal/wire/testdata/Varargs/want/wire_gen.go
@@ -1,6 +1,6 @@
 // Code generated by Wire. DO NOT EDIT.
 
-//go:generate go run github.com/google/wire/cmd/wire
+//go:generate go run -mod=mod github.com/google/wire/cmd/wire
 //go:build !wireinject
 // +build !wireinject