Skip to content

Code generation for google.protobuf.Empty produces invalid type *pb.google_protobuf_Empty #3715

@HeimaoLST

Description

@HeimaoLST

What happened:

When using google.protobuf.Empty as a request or response type in a .proto file, the kratos proto server command generates service code that references a non-existent type *pb.google_protobuf_Empty. This results in a compilation error.

What you expected to happen:

The generator should instead use *emptypb.Empty from the google.golang.org/protobuf/types/known/emptypb package.

How to reproduce it (as minimally and precisely as possible):

1.Define a .proto file with google.protobuf.Empty
2.run

   kratos proto server api/myservice/v1/my_service.proto -t internal/service
   ```

#### Anything else we need to know?:

#### Environment:
- Kratos version (use `kratos -v`):v2.8.4
- Go version (use `go version`): 1.25.1
- OS (e.g: `cat /etc/os-release`): Ubuntu-24.04
- Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions