Skip to content

detecting import paths is incorrect for root vanity imports #280

@marwan-at-work

Description

@marwan-at-work

Perhaps the comment in this line of code describes the issue best:

// The presence of a slash implies there's an import path.

An import path may not actually have a slash in it. For example if you define a vanity import such as "go.mycompany.com" and then define your protobuf file at the root of the module as such:

syntax = "proto3";
package mycompany;
option go_package = "go.mycompany.com;mycompany";

...

Twirp will end up generating the following Go package declaration:

package go_mycompany_com_mycompany

...

This is clearly incorrect. Twirp should instead see if there's a semi-colon in the go_package option and then return the left hand side as the import path and the right hand side as the package name.

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