12.4 Example: Encoding S-Expressions
Display
is a debugging routine for displaying
structured data, but it’s not far short of being able to
encode or marshal arbitrary Go objects as messages in a
portable notation suitable for inter-process communication.
As we saw in Section 4.5, Go’s standard library supports a variety of formats, including JSON, XML, and ASN.1. Another notation that is still widely used is S-expressions, the syntax of Lisp. Unlike the other notations, S-expressions are not supported by the Go standard library, not least because they have no universally accepted definition, despite several attempts at standardization and the existence of many implementations.
In this section, we’ll define a package that encodes arbitrary ...
Get The Go Programming Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.