src-d / proteus

Generate .proto files from Go source code.
https://blog.sourced.tech/post/proteus/
MIT License
735 stars 70 forks source link

Proteus is generating a proto message even when the struct is not marked for generation: #96

Open aantelov87 opened 6 years ago

aantelov87 commented 6 years ago

the structs are not marked for generation but proteus is generating a proto file with a Address message related to Address type from go code. Check below what I am doing:

package order

type Address struct {
    City    string
    Country string
    Line1   string
    Line2   string
    ZipCode string
    State   string
}

type Shipping struct {
    Address        *Address
    Carrier        string
    FirstName      string
    LastName       string
    Phone          string
    TrackingNumber string
}

Output after proteus execution:

syntax = "proto3";
package example.pkg.order;

import "github.com/gogo/protobuf/gogoproto/gogo.proto";

option (gogoproto.protosizer_all) = true;
option (gogoproto.sizer_all) = false;
option go_package = "order";

message Address {
    option (gogoproto.goproto_getters) = false;
    option (gogoproto.typedecl) = false;
    string city = 1;
    string country = 2;
    string line1 = 3;
    string line2 = 4;
    string zip_code = 5;
    string state = 6;
}

Expected output:

syntax = "proto3";
package example.pkg.order;

import "github.com/gogo/protobuf/gogoproto/gogo.proto";

option (gogoproto.protosizer_all) = true;
option (gogoproto.sizer_all) = false;
option go_package = "order";

I think that is a bug because it is working proper if the Address type is embedded in the Shipping type for example:

package order

type Address struct {
    City    string
    Country string
    Line1   string
    Line2   string
    ZipCode string
    State   string
}

type Shipping struct {
    Address
    Carrier        string
    FirstName      string
    LastName       string
    Phone          string
    TrackingNumber string
}
jwilander commented 6 years ago

I'm seeing this as well