-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
mockgen
flag --build_constraint
to add //go:build
directi…
…ves (#191) Resolves #190 Note that `//go:generate` has unusual handling of flags with spaces so the quotes have to include the flag name ([example](https://github.com/ARR4N/mock/blob/36b5e87796c7f82be7275e40bd54965c8605875c/mockgen/internal/tests/build_constraint/input.go#L3)) for complex constraints. This revealed a bug in `--write_generate_directive`, which just prints space-delimited `os.Args`. The workaround of using `--copyright_file` is neither viable (it adds a space between `//` and `go:build`) nor good practice as overloading functionality can result in bugs due to unanticipated usage (e.g. the aforementioned space).
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package empty_interface | ||
|
||
//go:generate mockgen -package empty_interface -destination mock.go -source input.go "-build_constraint=(linux && 386) || (darwin && !cgo) || usertag" | ||
|
||
type Empty interface{} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters