Skip to content

Latest commit

 

History

History
50 lines (33 loc) · 1.23 KB

README.md

File metadata and controls

50 lines (33 loc) · 1.23 KB

Fork of Protobuf Golang specialized for type generation

This package supposed to focus on type generation based on proto file.

Features compared to original repository

  • Flags to REMOVE protobuf specific field generation
  • Make difference between optional and non-optional in case of structs. So it's generating non-pointer in case of non-optional

Installation

go install github.com/infiniteloopcloud/protoc-gen-go-types@latest

Flags

These are actually environment variables.

  • SKIP_PROTOBUF_SPECIFIC=false - Skip protobuf specific code
  • TYPE_OVERRIDE - Enable type override

Type override

Supported overwrite:

  • TimeTime -> time.Time
  • RepeatedString -> []string

Example

syntax = "proto3";

message SomeStruct {
  TimeTime created_at = 1; // This will be time.Time
}

message TimeTime {}

Important

Currently the overwritten FieldOptions (go_type, go_import, go_import_alias, go_zero_override) must be paired with these numbers: go_type = 1001 go_import = 1002 go_import_alias = 1003 go_zero_override = 1004 go_struct_tags = 1005 Because protoc can't process the extended options, so we can't find the by name, just by place.