Leanpub Header

Skip to main content

A Go Developer's Notebook

Where I Go During My Holidays

A Go Developer's Notebook is a living book about the Go language and programming in general, written by a long-standing member of the Go community and based on her experience working with Go since its initial public release in November 2009.

Minimum price

$10.00

$25.00

You pay

$25.00

Author earns

$20.00
$

...Or Buy With Credits!

You can get credits monthly with a Reader Membership
PDF
EPUB
WEB
1,411
Readers
398
Pages
About

About

About the Book

This is the book that I wish had existed when I first started exploring the Go language, built around code examples I could have played with at my own pace.

It's also like the book I wish had existed when I first started programming - an amalgam of the magazine articles which taught me to code and the wisdom (or not) conferred by forty-plus years of doing just that. I hope it's as readable to the interested teenager taking their first steps into hacking as it is the university graduate armed with a wealth of theory but looking for practical insight.

It's also more generally a book about reading and writing code, and about many areas of computing which fascinate me. Perhaps they'll fascinate you too!

One thing this isn't is a professional book, by which I mean that it's not concerned with helping a professional developer quickly transition from another programming language to Go. There are plenty of those already in print, written by much better teachers than me. Instead my aim in this text is to provide a much deeper exploration of subjects I'm interested in through the lens of Go, teaching the language almost as an after-thought.

The didactic style is brutally simple and old-school: write code, explain code, modify code, explain changes, repeat as necessary. Along the way I'll do my best to explain what each example is trying to achieve, and the thinking which evolves it towards its final form.

Each chapter is built around a particular programming task which I use to demonstrate how various features of the Go language can be used as well as to share many of the things I've learned during several decades of coding. Some of these programming tasks may appear deceptively simple, others totally irrelevant to the life of a commercial developer. I intend to disabuse you of both notions, whilst at the same time keeping this a Hacker's Notebook: depending on your outlook this is either a logbook of experiments undertaken and rabbit-holes delved in pursuit of knowledge, or a grimoire of the esoteric and unutterably unconscionable.

If the choice of subject matter at times seems eccentric, remember that my target audience is my teenage self, hunched starry eyed and clueless over an 8-bit micro, not the fiftysomething code diva I've since become. My teenage self knew nothing about reading code, testing, refactoring, the scientific method, clean coding style, or academic theory.

As the reader you don't need to know any of these things either, though if you do I hope you'll still find some useful nuggets to add to your toolkit. And if you don't, then hopefully some of that will rub off and prove useful to you in other areas of your life.

So in essence this is a book inspired by my love of programming for the sake of programming, my disillusionment with the widespread desire to teach professional programming at the expense of exploration and fun, and my hope that readers of all ages will find the same pleasure in reading this book that I've experienced in researching and writing it.

There's a public github repo with the code for each completed narrative section.

To further whet your appetite I provide a free sample comprising an introduction to concurrent network programming with Go that includes practical encryption and is probably sufficient for a professional developer to get up to speed with the language (currently in its pre-Generics form). If that's all you're after, enjoy this free gift.

I've also given a brief presentation on the philosophy behind this living book.

Author

About the Author

Eleanor McHugh

London-based hacker Ellie has a passion for the esoteric corners of programming stretching back to her misspent teenage years. During the course of her career she's worked on mission critical systems ranging from avionics to banking security and now devotes her time to writing digital romances in Ruby and Go.

As a responsible parent she enjoys polyhedral dice, home brewing and gothic music.

Contents

Table of Contents

Preface

  1. Introducing Go
  2. Getting Started
  3. So what is Go?
  4. Open source
  5. Efficient compilation
  6. Efficient execution
  7. Ease of programming
  8. And where did it come from?
  9. Into the wild
  10. Where next?

Hello World

  1. Packages
  2. Constants
  3. Variables
  4. Functions
  5. Encapsulation
  6. Generalisation
  7. Startup
  8. HTTP
  9. The Environment
  10. Handling Signals
  11. TCP/IP
  12. UDP
  13. RSA obfuscated UDP
  14. Error Handling
  15. Exceptions
  16. Why doesn’t Go have native exceptions?
  17. Why does Go not have exceptions?
  18. Dynamism comes at a price

Echo

  1. TO DO:
  2. Arguments
  3. Flags
  4. TO DO
  5. Command-line Boilerplate and Standard I/O
  6. TO DO
  7. Conditional Flags
  8. Errors
  9. TO DO
  10. Files
  11. Regular Expressions
  12. Interactive
  13. Pipes
  14. Encryption

Chat

  1. TO DO

URL Shortener

  1. TO DO
  2. Going Loopy
  3. Adventures in Iteration

Linear Sequences

  1. The for {} construct
  2. User Defined Slices
  3. Iterating Through Arrays
  4. Arrays and Slices Exposed
  5. type SliceHeader
  6. Iteration and structured types
  7. reflect.Values and allocated memory
  8. validity
  9. addressability
  10. interfaceability
  11. setability

mappings

  1. TO DO
  2. Iteration and maps

Going Loopy Part n

  1. Closures
  2. Concurrency
  3. Asynchrononus channels
  4. Channel buffering equivalence
  5. Select
  6. Duck-typing
  7. Reflection
  8. User defined types
  9. Interface types
  10. Software Machines

Software Machines

  1. array stacks
  2. cactus stacks
  3. hash maps
  4. heaps
  5. switch dispatchers
  6. direct threaded dispatchers
  7. indirect threaded dispatchers
  8. assembler
  9. tail calls
  10. architectures
  11. fun with types
  12. timers
  13. Instruction Set
  14. processor core
  15. accumulator machine
  16. stack machine
  17. register machine
  18. vector machine
  19. TO DO

Software Machines

  1. memory
  2. Functional Programming
  3. Metaprogramming and First-Class Functions
  4. Pure Functions, Expressions, and Recursion
  5. Partial Application and Currying
  6. Lazy Evaluation and Memoization
  7. Infinite Series and Data Structures
  8. Immutability
  9. Values vs References
  10. Immutable Container Types
  11. The Cons Cell
  12. Singly-linked Lists
  13. Spaghetti Stacks
  14. Queues
  15. Types
  16. Category Theory
  17. Monads & Side-Effects
  18. Tail Call Elimination
  19. Trampolining

Functions

  1. The Machine View
  2. Adding Human Readability
  3. Procedures and Functions in Go
  4. The Mathematical View
  5. Simple Factorials
  6. First-Class and Higher-Order Functions
  7. Closures
  8. Currying
  9. Recursion
  10. funcs() Which Call Themselves
  11. Mathematical Functions Which Call Themselves
  12. Error Handling the Go Way
  13. Changing Types
  14. Why is working with big.Int so frustrating?

Memoization

  1. A Shallow Introduction to Big-O Notation
  2. In-Memory Caching
  3. Private Caches
  4. Caches in Hashes
  5. Once Upon A Flat File
  6. Let’s Talk About Type
  7. utility.go
  8. cache.go
  9. main.go
  10. A Generalised Cache
  11. cache.go
  12. utility.go
  13. factorial.go
  14. diskcache.go
  15. main.go
  16. Explicitly Layered Caching
  17. A Dedicated Memory Cache
  18. Writing Files in a Functional Manner
  19. Preventing Concurrent Writes
  20. Sharing Locks Between Processes
  21. A Dedicated Disk Cache
  22. Combining Caches
  23. Caches in Random Access Files
  24. Caches in Databases
  25. Caches on the Network
  26. Networks as Caches
  27. Encrypted Caches

Immutable Structures

Lazy Evaluation

  1. Partial Application

Monads

  1. If Not “Is” Then “What For”?
  2. Logic Programming
  3. Unification
  4. Odds & Sods

Maps and Hashes

  1. TO DO
  2. Go maps
  3. A simple Map implementation

Types

  1. TO DO
  2. Primitives
  3. Methods
  4. References
  5. Object Orientation
  6. Structures
  7. Embedding
  8. User defined types, pt 2
  9. User defined types, pt 3
  10. Testing types
  11. Type embedding
  12. Benchmarking types
  13. Interfaces
  14. Interfaces, pt 1
  15. package adder
  16. TO DO

Pretty Pictures

  1. TO DO
  2. TO DO
  3. Basic Mandelbrot

Phong Shading

Communication by Sharing

  1. TO DO

Concurrency

  1. synchronous
  2. asynchronous
  3. map/reduce
  4. map/reduce

Errors, Exceptions & Flow Control

  1. Catch & Throw
  2. Stack Traces
  3. Exceptions

Lists, Stacks, Dictionaries, and Queues

  1. TO DO

Duck Typing, Reflection and Type Manipulation

  1. package generalise
  2. raw
  3. find underlying type

Beyond Go

  1. Encryption and Privacy
  2. Accessing System Services
  3. Interfacing with Dynamic Libraries
  4. SQLite 3
  5. Ruby?

Network Adventures

  1. TO DO

Platform Fun

  1. TO DO
  2. Those Other Languages

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub