This will allow us to like to specific snippets of code in the
documentation. I plan to create a tutorial similar to the C# tutorial
https://developers.google.com/protocol-buffers/docs/csharptutorial
Since that tutorial has sections for populating a proto, parsing, and
serializing, I made a region for each of these for Go. To make the
populating sample more self-contained, I refactor the listing example
slightly.
Since these tags might be confusing, added a note that these are not
part of the normal protocol buffers syntax. I also linked to the main
tutorials page that uses these examples
https://developers.google.com/protocol-buffers/docs/tutorials so that
anyone who arrived here without going through that info first can get
more explanation if they want.
This follows the other examples so that it can be used as a tutorial,
such as the ones at:
https://developers.google.com/protocol-buffers/docs/tutorials
Even though Go generally does not use Makefiles, I added targets for the
Go examples to be consistent with the other languages.
Edit:
Fix Travis run. Change to use $HOME instead of ~. Add protoc to path.
GOPATH entry cannot start with shell metacharacter '~': "~/gocode"
Edit(2):
Fix Go code style to address comments.
To my surprise, executing generate_protos.sh used the version of Bash installed with Git for Windows by default.
After a few modifications to detect the most appropriate protoc to use, this worked pretty simply.
This change also:
- adds generation of the address book tutorial proto,
- fixes the addressbook.proto to specify proto2 explicitly (to avoid a warning from protoc; I don't think we want warnings...)
- fixes the addressbook.proto C# namespace (which I thought I'd done before, but apparently hadn't)
- includes the regenerated UnittestCustomOptions.cs apart from the DescriptorProtoFIle => Descriptor change