Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Gazelle deletes grpc dependencies if put mock in a go_library. Possible output mock file in directory instead of bazel-in? #57

Open
toyokaku opened this issue May 24, 2021 · 1 comment

Comments

@toyokaku
Copy link

go_library(
    name = "server",
    srcs = [
        "server.go",
        ":hello_go_mock",
    ],
    importpath = "depot/codelab/hello/server",
    visibility = ["//visibility:public"],
    deps = [
        "//codelab/proto/hello",
        "@com_github_golang_mock//gomock",
        "@org_golang_google_grpc//:go_default_library",
    ],
)

gomock(
    name = "hello_go_mock",
    out = "hello_mock.go",
    interfaces = [
        "HelloClient",
        "HelloServer",
    ],
    library = "//codelab/proto/hello",
    package = "server",
)

other package needs this mock so I put it in go_library
However after bazel run //:gazelle

go_library(
    name = "server",
    srcs = [
        "server.go",
        ":hello_go_mock",
    ],
    importpath = "depot/codelab/hello/server",
    visibility = ["//visibility:public"],
    deps = ["//codelab/proto/hello"],
)

gomock(
...
)

deps are gone and tests will fail
I have to put # gazelle: ignore in the BUILD file that contains gomock()

Any option to generate file in the directory instead of bazel-bin?

@jmhodges
Copy link
Owner

Hm, I wonder if there's a way for bazel_gomock to convince gazelle to leave this alone without special casing. Generating a file to go into source hasn't, in the past, been the Bazel Go Way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants