Programming in Go

Creating Applications for the 21st Century
by Mark Summerfield

ISBN-10: 0321774639  – ISBN-13: 978-0321774637

Due for Publication May 2012

The purpose of this book is to teach solid idiomatic Go programming using all the features the language provides, as well as the most commonly used Go packages, and also to serve as a useful reference once the language is learned. The reader is assumed to have programming experience in a mainstream programming language such as C, C++, Java, Python, or similar, although all of Go's unique features and idioms are illustrated with complete runnable examples that are fully explained in the text.

Go runs on most Unix-like operating systems such as Linux and Mac OS X, and also on Windows. The book's examples and exercise solutions have been tested on all of these platforms and will be available for download as soon as the book is published in print form.

The book will be useful to people who program professionally as part of their job, whether as full-time software developers, or those from other disciplines, including scientists and engineers, who need to do some programming in support of their work. It will also be useful to students who have had a reasonable amount of programming experience.

Go provides high level features such as slices (in effect variable length arrays) and maps (hash tables). Go can be used for procedural and object-oriented programming (or a combination of both). Go's approach to object orientation is unusual being based on aggregation and delegation, interfaces, and duck typing, rather than inheritance and virtual (overridable) methods. Go has a garbage collector to relieve programmers from the burdens of manual memory management. Built into the Go language is support for a version of CSP (Concurrent Sequential Processes) using channels that makes writing concurrent programs a lot easier than the traditional threading approaches—it is perfectly possible to write highly concurrent Go programs that contain no explicit locks at all.

Arguably, C++, Objective-C, and Java (the latter indirectly as a “better C++”), have all attempted to be better C's. Go can also be seen as an attempt to be a better C, even though Go's clean light syntax is reminiscent of Python—and Go's slices and maps are very similar to Python's lists and dicts. However, Go is probably closer in spirit to C than to any other language, and can be seen as an attempt to avoid all of C's drawbacks while providing all that's best in C, as well as its own powerful and useful features.

The book has benefited enormously from technical reviews by a couple of expert Go programmers—and from feedback from some non-Go programmers to ensure that the book teaches everything it should and is understandable to those new to Go.

Drafts of the chapters written so far are available from Safari—note that these can be up to a few months out of date although they will catch up within a few months of physical publication.

The book will be around ~450 pages, and will be published by Addison-Wesley Professional as soon as possible after the official release of Go 1 (i.e., as soon as the text, examples, and exercise solutions are Go 1 compliant). The book can be preordered from Amazon.com or Amazon.co.uk, or from your preferred online or local book store.

Only the printed editions are definitive—although available in electronic formats, "ebooks" usually restrict your rights, and they are often retypeset which can introduce errors.

Programming in Go book cover

Table of Contents—most chapters also have at least one exercise

  • Chapter 9. Packages
  • Appendix A: Epilogue
  • Appendix B: The Dangers of Software Patents
  • Appendix C: Selected Bibliograpy
  • Index
  • For more about Go see golang.org.

    Like all my books and most of my other writings, this book was written using The Lout Typesetting System.

    Top