protoc-gen-gorm icon indicating copy to clipboard operation
protoc-gen-gorm copied to clipboard

Google's timestamppb only imported for side effects in generated file.

Open raypendergraph opened this issue 3 years ago • 0 comments

Just using the google.protobuf.Timestamp in a message causes timestamppb to be imported but only for side effects _ "google.golang.org/protobuf/types/known/timestamppb". This causes build errors as this package is referenced in the code when dealing with these properties. Removing the generated _ completely solves the issue but this is such a common use case I'm wondering if I'm doing something wrong.

import "google/protobuf/timestamp.proto";

message MyMessage {
    ...
     google.protobuf.Timestamp start_time = 3;
     string preferences = 4 [(gorm.field).tag = {not_null: true}];
     ...
}

Is there any way to force this to import? I'm on Go 1.17x if it's important. And building with buf

raypendergraph avatar Jan 25 '22 20:01 raypendergraph