Skip to content

Code from a message-only proto file includes unused code #8

Description

@jvillafanez

Steps to reproduce

  1. Create a message.proto file with only "Message" definition. It's intended to be used as common data type definition
  2. Create a service.proto file with a "Service" definition that imports from the message.proto file.
  3. Generate the code.

Current result

The generated code includes imports "net/http", "github.com/go-chi/chi/v5" and "github.com/go-chi/render" which aren't used.

Example generated code: https://github.com/jvillafanez/prototest001/blob/abf38bb9e4aa6da50ff0c97d59a26ba9905cffd6/gen/ocis/messages/v1/config.pb.web.go

Trying to use / compile the generated code fails.

...../github.com/jvillafanez/prototest001/gen@v0.0.0-20211202132711-abf38bb9e4aa/ocis/messages/v1/accounts.pb.web.go:9:2: imported and not used: "net/http"
...../github.com/jvillafanez/prototest001/gen@v0.0.0-20211202132711-abf38bb9e4aa/ocis/messages/v1/accounts.pb.web.go:11:2: imported and not used: "github.com/go-chi/chi/v5" as chi
...../github.com/jvillafanez/prototest001/gen@v0.0.0-20211202132711-abf38bb9e4aa/ocis/messages/v1/accounts.pb.web.go:12:2: imported and not used: "github.com/go-chi/render"
...../github.com/jvillafanez/prototest001/gen@v0.0.0-20211202132711-abf38bb9e4aa/ocis/messages/v1/config.pb.web.go:9:2: imported and not used: "net/http"
...../github.com/jvillafanez/prototest001/gen@v0.0.0-20211202132711-abf38bb9e4aa/ocis/messages/v1/config.pb.web.go:11:2: imported and not used: "github.com/go-chi/chi/v5" as chi
...../github.com/jvillafanez/prototest001/gen@v0.0.0-20211202132711-abf38bb9e4aa/ocis/messages/v1/config.pb.web.go:12:2: imported and not used: "github.com/go-chi/render"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions