raul

raul

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

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New
akraut
The markup used to display the uploaded image results in a Phoenix.LiveView.HTMLTokenizer.ParseError error. lib/pento_web/live/product_l...
New
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
New
rainforest
Hi, I’ve got a question about the implementation of PubSub when using a Phoenix.Socket.Transport behaviour rather than channels. Before ...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
New
New
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New

Sub Categories: