Skip to content

infiniteloopcloud/protoc-gen-go-types

 
 

Repository files navigation

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.

About

Fork of Protobuf Golang specialized for type generation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.8%
  • Other 0.2%