Skip to content

Commit

Permalink
import mode renamed to package mode in:
Browse files Browse the repository at this point in the history
* tests
* help message
* README.md
  • Loading branch information
tulzke committed Sep 27, 2024
1 parent 6fc5cf5 commit 69210e9
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 781 deletions.
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export PATH=$PATH:$(go env GOPATH)/bin

## Running mockgen

`mockgen` has two modes of operation: source and reflect.
`mockgen` has two modes of operation: source and package.

### Source mode

Expand All @@ -54,11 +54,10 @@ Example:
mockgen -source=foo.go [other options]
```

### Reflect mode
### Package mode

Reflect mode generates mock interfaces by building a program
that uses reflection to understand interfaces. It is enabled
by passing two non-flag arguments: an import path, and a
Package mode works by specifying the package and interface names.
It is enabled by passing two non-flag arguments: an import path, and a
comma-separated list of symbols.

You can use "." to refer to the current path's package.
Expand Down Expand Up @@ -98,8 +97,6 @@ It supports the following flags:
`foo=bar/baz.go`, where `bar/baz.go` is the source file and `foo` is the
package name of that file used by the -source file.

- `-build_flags`: (reflect mode only) Flags passed verbatim to `go build`.

- `-mock_names`: A list of custom names for generated mocks. This is specified
as a comma-separated list of elements of the form
`Repository=MockSensorRepository,Endpoint=MockSensorEndpoint`, where
Expand All @@ -119,15 +116,11 @@ It supports the following flags:

- `-debug_parser`: Print out parser results only.

- `-exec_only`: (reflect mode) If set, execute this reflection program.

- `-prog_only`: (reflect mode) Only generate the reflection program; write it to stdout and exit.

- `-write_package_comment`: Writes package documentation comment (godoc) if true. (default true)

- `-write_generate_directive`: Add //go:generate directive to regenerate the mock. (default false)

- `-write_source_comment`: Writes original file (source mode) or interface names (reflect mode) comment if true. (default true)
- `-write_source_comment`: Writes original file (source mode) or interface names (package mode) comment if true. (default true)

- `-typed`: Generate Type-safe 'Return', 'Do', 'DoAndReturn' function. (default false)

Expand Down
2 changes: 1 addition & 1 deletion mockgen/internal/tests/generics/generics.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

//go:generate mockgen --source=generics.go --destination=source/mock_generics_mock.go --package source
//go:generate mockgen --destination=import_mode/mock_test.go --package=import_mode . Bar,Universe,MilkyWay,SolarSystem,Earth,Water
//go:generate mockgen --destination=package_mode/mock_test.go --package=package_mode . Bar,Universe,MilkyWay,SolarSystem,Earth,Water

type Bar[T any, R any] interface {
One(string) string
Expand Down
23 changes: 0 additions & 23 deletions mockgen/internal/tests/generics/import_mode/import_mode_test.go

This file was deleted.

Loading

0 comments on commit 69210e9

Please sign in to comment.