owncloud / owncloud/protoc-gen-microweb

Code from a message-only proto file includes unused code

Open
#8 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
8
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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"

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the message.proto and service.proto reproduction, then inspect the generated .pb.web.go files linked in the report. Generate code for a message-only proto import and compile the result to confirm the unused imports. Done means generated files for this case compile without unused net/http, chi, or render imports.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend-api-design, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.