March 2021
Intermediate to advanced
260 pages
5h 45m
English
In the previous chapter, we defined our Record type in Go as this struct:
| | type Record struct { |
| | Value []byte `json:"value"` |
| | Offset uint64 `json:"offset"` |
| | } |
To turn that into a protobuf message we need to convert the Go code into protobuf syntax.
The convention for Go projects is to put your protobuf in an api directory. So run mkdir -p api/v1 to create your directories, then create a file called log.proto in the v1 directory and put this code in it:
| | syntax = "proto3"; |
| | |
| | package log.v1; |
| | |
| | option go_package = "github.com/travisjeffery/api/log_v1"; |
| | message Record { |
| | bytes value = 1; |
| | uint64 ... |
Read now
Unlock full access