protogen

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

protogen

BACKGROUND

Assume we have a big project like hdmall, it has many sub projects, each sub project may use protobuf types defined in other sub projects, the easiest way is put all proto files belong to different sub projects into same directory and just name it with different filename, then compile all proto files into one package. e,g:

proto/
    ...
    order.proto
    product.proto
    ...

will generate souce codes in autogen/pb directory

autogen/
    pb/
        ...
        order.pb.go
        product.pb.go
        ...

But the drawback is the final built binary file is too large, it will include all protobuf types defined in all proto files, which is not necessary.

INTRODUCTION

Fortunately, this tool is developed to find all protobuf types referenced in source codes, then extract the protobuf type definitions from center proto files repository, at last generate new proto source file which only contains protobuf types we needed.

INSTALL
go install github.com/hdget/protogen
USAGE
Usage:
   [flags]

Flags:
  -h, --help                 help for this command
      --output-dir string    output directory
      --package string       protobuf package name used in source code (default "pb")
      --project-dir string   project directory
      --proto-dir string     proto directory
      --suffix string        file suffix (default ".go")

protogen --project-dir=/tmp/project --proto-dir=/tmp/proto --output-dir=/tmp/project/proto
LIMITATION
  • it only support find protobuf types from golang source codes
  • it only supports gogo options
  • 3rd party protobuf types only supported following:
    • google.protobuf.Any
    • hdsdk.protobuf

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL