Distributed Services with Go: Chapter 2 suggestions

Hi TJ, Suggestions on Chapter 2 of the book:

To send data (such as your structs) over a network

  • Not sure whether a layperson would translate structs mentally to the same intended here

• Guarantees type-safety;
• Prevents schema-violations;

  • Sorry if it’s a dumb question but how are these two different?

http://media.pragprog.com/titles/tjgo/code/StructureDataWithProtobuf/example.proto

  • syntax = “proto3”; is repeated twice in the file - is that intended?
  • What about the Person and Animal entries? Do they need to be removed? Along with the import setter possibly.

http://media.pragprog.com/titles/tjgo/code/StructureDataWithProtobuf/example.pb.go

So run mkdir -p api/v1 to create your directories

  • Maybe mention this is in a different top-level directory than the one in chapter 1?
  • Also is the StructureDataWithProtobuf/ the same for all of Chapter 2?

and with protobuf you put the name of the field on right followed by its name (with an additional field id).

  • put the ‘name’ of the field → put the ‘type’ of the field?

if you look at Google’s API definitions[GitHub - googleapis/googleapis: Public interface definitions of Google APIs.] protobuf

  • Where is the version bump indicated exactly, I could see only v1s?

protoc api/v1/*.proto \ --gogo_out=Mgogoproto/gogo.proto=github.com/gogo/protobuf/proto:. \ --proto_path=$(go list -f ‘{{ .Dir }}’ -m github.com/gogo/protobuf) \ --proto_path=.

  • Output with the slashes on MacOS Catalina 10.15.7: Missing output directives.
  • Removed the slashes: protoc api/v1/*.proto --gogo_out=Mgogoproto/gogo.proto=github.com/gogo/protobuf/proto:. --proto_path=$(go list -f ‘{{ .Dir }}’ -m github.com/gogo/protobuf) --proto_path=.
  • Ran successfully and generated the log.pb.go

it’s worth adding a Makefile with a compile target that you can quickly run again and again

  • Maybe add ‘run with make or make compile’ for people not familiar with make?
  • The make command did succeed in generating the pb.go with no issues

imagine you’re building a retail site like Amazon and have different types stuff you sell

  • different types stuff → different types 'of ’ stuff