jmhodges / bazel_gomock

Code to create Go mocks for bazel targets using mockgen
MIT License
59 stars 29 forks source link

setting default package name when self_package is known #26

Open linzhp opened 5 years ago

linzhp commented 5 years ago

When self_package is passed, it is possible to infer package name parameter so users don't need to pass duplicate information

jmhodges commented 4 years ago

Could you post the build target you're needing to use this in? I'm trying to figure out how this and #28 are operating differently

linzhp commented 4 years ago

I agree with https://github.com/jmhodges/bazel_gomock/pull/28#issuecomment-543095961, this PR is different from #28. This is more for convenience. If we know the full package path via self_package, the package name can be deduced from that for most cases. It allows us to do something like:

gomock(
    name = "private_mocks",
    out = "mocks.go",
    interfaces = [
        "test",
    ],
    library = ":go_default_library",
    self_package = "github.com/josmad/go_samples/mock_test",
)

Note that package attribute is missing, and the rule uses mock_test by default

linzhp commented 4 years ago

@jmhodges Any more concerns on this PR?