Skip to content

ozwin/ProtoBuffer3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GO ProtoBuffer3

Demo of Protocol buffer 3 with GO

Installation

Download the proto3 compiler from https://github.com/protocolbuffers/protobuf/releases/tag/v3.14.0 and keep the exe in GOPATH e.g C:\Users{Name}\go\bin and copy the include folder from the zip to same folder e.g C:\Users{Name}\go

Run the below command to add the protobnf plugin for GO

go get github.com/golang/protobuf/protoc-gen-go 

Step 1 : Create a file with .proto extension to create message e.g addressbook.proto

option go_package = "./output"; -> Use a directory path where the generated code should be stored

run the below command to generate code for the .proto file protoc -I={exact directory path} --go_out={exact directory path} {exact directory path}\addressbook.proto

Import the generated file output/addressbook.pb.go in your code

e.g import (pb "./output)

How to run

To add a entry to the file addressbook.data

go run .\addPerson.go addressbook.data

To list the data

go run .\ListPerson.go addressbook.data

About

Demo of Protocol buffer 3 with GO

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages