Skip to content

Multiple packages with the same "leaf" package name can cause go.lint options to be ignored. #92

Description

@bithoarder

If multiple packages have the same "leaf" package name (package1/messages/, package2/messages/), then the linting will sometimes be skipped for one of the packages.

It's easiest to describe with a small example:

v1/a/test.proto:

syntax = "proto3";
package test.v1.a;
option go_package = "foo/bar/v1/a";

v2/a/anothertest.proto:

syntax = "proto3";
package test.v1.a;
option go_package = "foo/bar/v2/a";

import "patch/go.proto";
option (go.lint).all = true;

enum SomeEnum {
  SOME_ENUM_UNDEFINED = 0;
  SOME_ENUM_FOO = 1;
}

Then, depending on the order the proto files are supplied to protoc, the generated enum might not be linted.

this failed to lint the enum:
protoc -I . --go-patch_out=plugin=go,paths=source_relative:.make v2\a\anothertest.proto v1\a\test.proto
this works:
protoc -I . --go-patch_out=plugin=go,paths=source_relative:.make v2\a\test.proto v1\a\anothertest.proto

I think this is because Patcher.packagesByName is only keyed by the "leaf" package name, and thus gets overwritten.

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