proto

module
v0.0.0-...-3840bb3 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0

README

protobuf

How to install:
  • Install "protocol buffers"

    https://github.com/protocolbuffers/protobuf
    

    or

    (MacOS)

    brew install protobuf
    
  • Install plugins to generate .go

    go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
    go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
    
How to upgrade (MacOS):
brew upgrade protobuf
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
How to run:
  • Add these 2 important lines to your ~/.bash_profile or ~/.zshrc:
    export GO_PATH=~/go
    export PATH=$PATH:/$GO_PATH/bin
    
  • Then close your terminal and re-open it, after that run:
    source ~/.bash_profile (source ~/.zshrc)
    
  • Run: Single file
    protoc -I. --go_out=plugins=grpc:. your_file_want_to_build.proto
    
    Build all
    make
    
How to test:
How to format .proto file(MacOS):
  • Install clang-format
    brew install clang-format
    
  • Generate .clang-format file
    clang-format -assume-filename=<any file *.proto you want> -style=llvm -dump-config > .clang-format
    
    EX: clang-format -assume-filename=tnx.proto -style=llvm -dump-config > .clang-format
  • Config clang format: Add or update below line to .clang-format which had been generated prev step.
    AlignConsecutiveAssignments: true
    AlignConsecutiveDeclarations: true
    
  • Add the following to your settings.json file:
    "[proto3]": {
        "editor.formatOnSave": true,
    },
    
  • Double save(Cmd + S) to see the magic

Directories

Path Synopsis
gen
go

Jump to

Keyboard shortcuts

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