~/devreads

Dave Cheney

https://dave.cheney.net/ · 220 posts · history since 2013 · active

18 Dec 2025

Dave Cheney 1 min read

Here’s a small quiz derived from some incorrect advice from an AI coding assistant. This program prints two timestamps; will they be a. Roughly the same time (ie, the same second)b. Roughly 10 seconds apartc. Something else Answer after the fold

go

27 Nov 2025

Dave Cheney 1 min read

Here’s a silly example extracted from real code. Does this program print true or false?

go

21 Feb 2024

Dave Cheney 1 min read

This morning a one line change had several of us tearing up the fabric of reality trying to understand why a failing test wasn’t failing, or, in fact, being run at all. Increasingly frantic efforts to upgrade/downgrade Go, run the tests on another machine, run the tests in CI, all served to only unnerve us […]

gotesting

5 Jan 2021

Dave Cheney 6 min read

Today’s post comes from a recent Go pop quiz. Consider this benchmark fragment. A convenience wrapper around sort.Sort(sort.StringSlice(s)), sort.Strings sorts the input in place, so it isn’t expected to allocate (or at least that’s what 43% of the tweeps who responded thought). However it turns out that, at least in recent versions of Go, each […]

goprogramming

15 Dec 2020

Dave Cheney 2 min read

Picture yourself, an engineer working at the hottest distributed microservices de jour, assigned to fix a bug. You jump into an unfamiliar codebase and quickly locate the line where the problem occurred. The fix is simple, just return early or substitute a default value in the case that one cannot be determined from your input. […]

programmingsmall ideas

19 Jun 2020

Dave Cheney 1 min read

The Go compiler’s SSA backend contains a facility to produce HTML debugging output of the compilation phases. This post covers how to print the SSA output for function and methods. Let’s start with a sample program which contains a function, a value method, and a pointer method: Control of the SSA debugging output is via […]

goprogrammingcompilergossafuncssa

24 May 2020

Dave Cheney 2 min read

Per the overlapping interfaces proposal, Go 1.14 now permits embedding of interfaces with overlapping method sets. This is a brief post explain what this change means: Let’s start with the definition of the three key interfaces from the io package; io.Reader, io.Writer, and io.Closer: Just as embedding a type inside a struct allows the embedded type’s […]

goprogrammingcompilerinterfaces

16 May 2020

Dave Cheney 5 min read

A few days ago Fatih posted this question on twitter. I’m going to attempt to give my answer, however to do that I need to apply some simplifications as my previous attempts to answer it involved a lot of phrases like a pointer to a pointer, and other unhelpful waffling. Hopefully my simplified answer can […]

goprogrammingjson

9 May 2020

Dave Cheney 5 min read

Conventional wisdom dictates that the larger the number of types declared in a Go program, the larger the resulting binary. Intuitively this makes sense, after all, what’s the point in defining a bunch of types if you’re not going to write code that operates on them. However, part of the job of a linker is […]

goprogramming

2 May 2020

Dave Cheney 6 min read

In the previous post I discussed how leaf inlining allows the Go compiler to reduce the overhead of function calls and extend optimisation opportunities across function boundaries. In this post I’ll discuss the limits of inlining and leaf vs mid-stack inlining. The limits of inlining Inlining a function into its caller removes the call’s overhead […]

goprogramminginliningoptimisationperformance

25 Apr 2020

Dave Cheney 6 min read

This is a post about how the Go compiler implements inlining and how this optimisation affects your Go code. n.b. This article focuses on gc, the de facto Go compiler from golang.org. The concepts discussed apply broadly to other Go compilers like gccgo and tinygo but may differ in implementation and efficacy. What is inlining? […]

goprogramminginliningoptimisationperformance

10 Mar 2020

Dave Cheney 1 min read

The testing package is one of my favourite packages in the Go standard library, not just because of its low noise approach to unit testing, but, over the lifetime of Go, it has received a steady stream of quality of life improvements driven by real world usage. The most recent example of this is, in […]

goprogrammingtestingunit test

1 Mar 2020

Dave Cheney 1 min read

Programmers have a tendency to be superstitious. Particularly, when a programmer hears that copies are expensive, they start to see them everywhere, especially when they learn that, in Go, every assignment is a copy. Consider this code; x is three orders of magnitude larger than y, is the assignment of x to a more expensive […]

goperformanceslices

23 Feb 2020

Dave Cheney 22 min read

This article was derived from my GopherCon Israel 2020 presentation. It’s also quite long. If you’d prefer a shorter version, head over to the-zen-of-go.netlify.com. A recording of the presentation is available on YouTube. How should I write good code? Something that I’ve been thinking about a lot recently, when reflecting on the body of my […]

gosmall ideasdesign

8 Dec 2019

Dave Cheney 5 min read

This is a thought experiment in API design. It starts with the classic Go unit testing idiom: func TestOpenFile(t *testing.T) { f, err := os.Open("notfound") if err != nil { t.Fatal(err) } // ... } What’s the problem with this code? The assertion. if err != nil { ... } is repetitive and in the […]

gosmall ideastesting

5 Dec 2019

4 Dec 2019

Dave Cheney 3 min read

Last year I had the opportunity to watch Cat Swetel’s presentation The Development Metrics You Should Use (but Don’t). The information that could be gleaned from just tracking the start and finish date of work items was eye opening. If you’re using an issue tracker this information is probably already (perhaps with some light data […]

small ideas

17 Nov 2019

16 Nov 2019

6 Oct 2019

Dave Cheney 2 min read

In the beginning, before the go tool, before Go 1.0, the Go distribution stored the standard library in a subdirectory called pkg/ and the commands which built upon it in cmd/. This wasn’t so much a deliberate taxonomy but a by product of the original make based build system. In September 2014, the Go distribution […]

goprogrammingpkgproject layout

24 Sept 2019

Dave Cheney 1 min read

APIs should be easy to use and hard to misuse. — Josh Bloch A good example of a simple looking, but hard to use correctly, API is one which takes two or more parameters of the same type. Let’s compare two function signatures: What’s the difference between these functions? Obviously one returns the maximum of […]

goprogramming

5 Sept 2019

Dave Cheney 3 min read

This is a post about performance. Most of the time when worrying about the performance of a piece of code the overwhelming advice should be (with apologies to Brendan Gregg) don’t worry about it, yet. However there is one area where I counsel developers to think about the performance implications of a design, and that […]

goprogrammingperformance

20 Aug 2019

Dave Cheney 6 min read

Go allows authors to write functions in assembly if required. This is called a stub or forward declaration. package asm // Add returns the sum of a and b. func Add(a int64, b int64) int64 Here we’re declaring Add, a function which takes two int64‘s and returns their sum.Add is a normal Go function declaration, […]

go

8 Jul 2019

Dave Cheney 11 min read

This article is based on my GopherCon Singapore 2019 presentation. In the presentation I referenced material from my post on declaring variables and my GolangUK 2017 presentation on SOLID design. For brevity those parts of the talk have been elided from this article. If you prefer, you can watch the recording of the talk. Readability […]

goprogrammingsmall ideas

5 Jul 2019

Dave Cheney 1 min read

On the 17th of July I’ll be giving a version of my High Performance Go workshop updated for the upcoming changes in Go 1.13. The event is free, as in puppy, however numbers are limited due to the venue size. The event will be held in the Sydney CBD, the address will be provided to […]

gohigh performance gotrainingworkshop

10 Jun 2019

Dave Cheney 9 min read

This essay is a derived from my dotGo 2019 presentation about my favourite feature in Go. Many years ago Rob Pike remarked, “Numbers are just numbers, you’ll never see 0x80ULL in a .go source file”. —Rob Pike, The Go Programming Language Beyond this pithy observation lies the fascinating world of Go’s constants. Something that is […]

goprogrammingsmall ideasconstantserror handling

18 May 2019

Dave Cheney 2 min read

I started working remotely in 2012. Since then I’ve worked for big companies and small, organisations with outstanding remote working cultures, and others that probably would have difficulty spelling the word without predictive text. I broadly classify my experiences into three tiers; Little r remote The first kind of remote work I call little r […]

small ideasremote work

14 May 2019

Dave Cheney 4 min read

In previous posts and presentations I talked about how to test, and when to test. To conclude this series of I’m going to ask the question, why test at all? Even if you don’t, someone will test your software I’m sure no-one reading this post thinks that software should be delivered without being tested first. […]

programmingtesting

7 May 2019

Dave Cheney 11 min read

I’m a big fan of testing, specifically unit testing and TDD (done correctly, of course). A practice that has grown around Go projects is the idea of a table driven test. This post explores the how and why of writing a table driven test. Let’s say we have a function that splits strings: // Split […]

goprogrammingtestingunit test

3 Apr 2019

Dave Cheney 1 min read

A short talk about unit testing that I gave at the Go London User Group last month. Links: Slides Playlist of videos from the March meetup

go

20 Feb 2019

17 Feb 2019

Dave Cheney 2 min read

The open source projects that I contribute to follow a philosophy which I describe as talk, then code. I think this is generally a good way to develop software and I want to spend a little time talking about the benefits of this methodology. Avoiding hurt feelings The most important reason for discussing the change you want […]

programmingsmall ideascontributingopen source

29 Jan 2019

Dave Cheney 2 min read

The name of a variable should describe its contents, not the type of the contents. Consider this example: var usersMap map[string]*User What are some good properties of this declaration? We can see that it’s a map, and it has something to do with the *User type, so that’s probably good. But usersMapis a map and Go, being a statically typed…

gonames

27 Jan 2019

Dave Cheney 5 min read

Go 2 aims to improve the overhead of error handling, but do you know what is better than an improved syntax for handling errors? Not needing to handle errors at all. Now, I’m not saying “delete your error handling code”, instead I’m suggesting changing your code so you don’t have as many errors to handle. […]

goerror handlingerrors

8 Jan 2019

Dave Cheney 2 min read

Writing a good Go package starts with its name. Think of your package’s name as an elevator pitch, you have to describe what it does using just one word. A common cause of poor package names are utility packages. These are packages where helpers and utility code congeal. These packages contain an assortment of unrelated functions, […]

go

30 Dec 2018

27 Dec 2018

Dave Cheney 3 min read

Garbage collection is a field with its own terminology. Concepts like like mutators, card marking, and write barriers create a hurdle to understanding how garbage collectors work. Here’s an analogy to explain the operations of a concurrent garbage collector using everyday items found in the workplace. Before we discuss the operation of concurrent garbage collection, let’s introduce […]

gosmall ideasgarbage collectiongc

15 Nov 2018

Dave Cheney 1 min read

What do you do if its the late 1950’s and you need to project live video? Overhead LCD projectors–let alone the computers to drive them–haven’t been invented yet. The answer is the Eidophor, the most bonkers overhead projection system you’ve probably never heard of. Original link

internets of interest

11 Nov 2018

3 Nov 2018

Dave Cheney 1 min read

Every since I started giving my High Performance Go workshop I’ve been fascinated with the physics of semiconductors. This presentation from Hope Conference ’09 doesn’t cover the latest EUV shenanigans, but does an excellent job of detailing the difficulties in semiconductor manufacturing ten years ago. The problems have only become more complicated as semiconductor fabs attempt […]

internets of interest

15 Oct 2018

6 Oct 2018

Dave Cheney 1 min read

A fascinating wide ranging interview with Dave Cutler, the creator of RSX-11M, VMS, and Windows NT. Bonus: Show Stopper!: The Breakneck Race to Create Windows NT and the Next Generation at Microsoft. The book on the early history of the creation of Windows NT.

internets of interestwindows nt

28 Sept 2018

26 Sept 2018

Dave Cheney 1 min read

The interaction between career development and on-call is actually really, really, bad. Bluntly, the profession takes on-call seriously, tries to be good at it, yet it is very very rare for this to be rewarded in any meaningful way. In 11 years at my previous employer, I never saw anyone get promoted for on-call performance. […]

internets of intereston-callsre

23 Sept 2018

16 Sept 2018

Dave Cheney 1 min read

Ousterhout’s opus is tearing up tech twitter at the moment. But for those outside the North American prime shipping service area, we’re shit out of luck until a digital version is available. Until then, here’s Ousterhout’s Google Tech talk: Slides: https://platformlab.stanford.edu/Seminar%20Talks/retreat-2017/John%20Ousterhout.pdf CS190: https://web.stanford.edu/~ouster/cgi-bin/cs190-winter18/index.php

internets of interest

15 Sept 2018

3 Sept 2018

Dave Cheney 3 min read

This is a short response to the recently announced Go 2 generics draft proposals Update: This proposal is incomplete. It cannot replace two common use cases. The first is ensuring that several formal parameters are of the same type: contract comparable(t T) { t > t}func max(type T comparable)(a, b T) T Here a, and […]

goprogramminggenerics

19 Aug 2018

Dave Cheney 1 min read

This weekend I’ve been freshening up the introductory material for a workshop that Francesc Campoy and I are teaching at GopherCon this month. As part of my research, these videos have been on high rotation. The first video by Sophie Wilson, the designer of the first ARM chip from which both the company and the line […]

internets of interest

16 Jul 2018

Dave Cheney 3 min read

In my previous post I converted httpstat to use Go 1.11’s upcoming module support. In this post I continue to explore integrating Go modules into a continuous integration workflow via Travis CI. Life in mixed mode The first scenario is probably the most likely for existing Go projects, a library or application targeting Go 1.10 […]

goprogrammingdependancy managementmodulestravis ci

14 Jul 2018

Dave Cheney 4 min read

Update: Since this post was written, Go 1.11beta2 has been released. I’ve updated the setup section to reflect this. Russ Cox kindly wrote to me to explain the reasoning behind storing the Go module cache in $GOPATH. I’ve included his response inline. This weekend I wanted to play with Ubuntu 18.04 on a spare machine. […]

goprogrammingdependancy managementmodulesvgo

12 Jul 2018

Dave Cheney 5 min read

This blog post was inspired by a conversation with a co-worker about using a slice as a stack. The conversation turned into a wider discussion on the way slices work in Go, so I thought it would be useful to write it up. Arrays Every discussion of Go’s slice type starts by talking about something […]

goprogrammingslices

29 May 2018

16 Jan 2018

Dave Cheney 8 min read

What does a distro provide? The most popular docker base container image is either busybox, or scratch. This is driven by a movement that is equal parts puritanical and pragmatic. The puritan asks “Why do I need to run init(1) just to run my process?” The pragmatist asks “Why do I need a 700 meg […]

programmingsmall ideas

8 Jan 2018

Dave Cheney 16 min read

This is an article about compiler directives; or as they are commonly known, pragmas. It’s derived from a talk of a similar name that I gave last year at GopherChina in Shanghai. But first, a history lesson Before we talk about Go, let’s talk a little about pragmas, and their history. Many languages have the notion […]

goprogrammingpragma

6 Jan 2018

4 Dec 2017

Dave Cheney 24 min read

This post is a slightly edited version of my November presentation to the San Francisco chapter of Papers We Love. The paper I have chosen tonight is a retrospective on a computer design. It is one of a series of papers by Gordon Bell, and various co-authors, spanning the design, growth, and eventual replacement of the companies iconic […]

historypdp-11

30 Nov 2017

Dave Cheney 2 min read

At a recent RubyConf, Chad Fowler presented his ideas for writing software systems that mirror the process of continual replacement observed in biological systems. The first principal of this approach is, unsurprisingly, to keep the components of the software system small–just as complex organisms like human beings are constituted from billions of tiny cells which […]

programmingsmall ideas

19 Sept 2017

Dave Cheney 1 min read

I wanted to write a few words about the postal survey on marriage law currently underway in Australia. As an Australian, our country and our government do so many things that make me ashamed; the poverty of our indigenous population, the inhumane treatment of refugees on Manus Island, and the maniacal desire to burn every […]

small ideas#voteyes

6 Sept 2017

Dave Cheney 5 min read

Everyone gets the same set of tools Something that had long puzzled me was the question “Why do some people [in the organisation] have root, and others do not?” It seemed to me that the reason the sysadmins had the root passwords, and everyone else had to raise tickets, was a tooling problem. Giving everyone […]

small ideasheptiokubernetes

23 Aug 2017

Dave Cheney 3 min read

In September i’ll be speaking about Go at events in Russia and Taiwan. DevFest Siberia 2017, September 23rd and 24th I’ve been accepted to give two presentations at the GDG Novosibirsk DevFest Siberia 2017 event in Russia. High performance servers without the event loop Conventional wisdom suggests that the key to high performance servers are native threads, […]

goprogramming

21 Aug 2017

Dave Cheney 2 min read

The Lear Siegler ADM-3A terminal is a very important artefact in computing history. If you want to know why your shell abbreviates $HOME to ~, it’s because of the label on the ~ key on the ADM-3A. If you want to know why hjkl are the de facto cursor keys in vi, look at the symbols above the […]

historyuseless trivia

20 Aug 2017

Dave Cheney 3 min read

This is an experience report about the use of, and difficulties with, the context.Context facility in Go. Many authors, including myself, have written about the use of, misuse of, and how they would change, context.Context in a future iteration of Go. While opinions differs on many aspects of context.Context, one thing is clear–there is almost unanimous agreement that […]

goprogrammingcontextgo2.0

9 Aug 2017

Dave Cheney 3 min read

This is an experience report about a gotcha in Go that catches every Go programmer at least once. The following program is extracted from a larger version that caused my co-workers to lose several hours today. package mainimport "fmt"type T struct{}func (t T) F() {}type P interface { F()}func newT() *T { return new(T) }type […]

goprogrammingexperience reportgo2.0

22 Jul 2017

Dave Cheney 3 min read

A long time ago, someone–I normally attribute this to David Symonds, but I can’t be sure he was the first to say it–said that the reason for adding generics to Go would be the reason for calling it Go 2.0. That is to say, adding generics to the language would be half baked if they […]

goprogramminggenericsgo2.0

20 Jun 2017

Dave Cheney 2 min read

This is a short post describing the procedure for discovering which version of Go was used to compile a Go binary. This procedure relies on the fact that each Go program includes a copy of the version string reported by runtime.Version() . Linker magic ensures that this value will be present in the final binary irrespective […]

goprogramminggdbldbllvm

18 Jun 2017

Dave Cheney 7 min read

In my previous post I discussed my concerns the additional complexity adding generics or immutability would bring to a future Go 2.0. As it was an opinion piece, I tried to keep it around 500 words. This post is an exploration of the most important (and possibly overlooked) point of that post. Indeed, the addition of […]

goprogramminggenericsimmutability

14 Jun 2017

Dave Cheney 2 min read

Fifteen years ago Python’s GIL wasn’t a big issue. Concurrency was something dismissed as probably unnecessary. What people really was needed was a faster interpreter, after all, who had more than one CPU? But, slowly, as the requirement for concurrency increased, the problems with the GIL increased. By the time this decade rolled around, Node.js and […]

goprogrammingsmall ideasgenericsgo2.0

11 Jun 2017

Dave Cheney 7 min read

This is a thought experiment, what would Go look like if we could no longer declare variables at the package level? What would be the impact of removing package scoped variable declarations, and what could we learn about the design of Go programs? I’m only talking about expunging var, the other five top level declarations would […]

goprogrammingsmall ideas

30 Apr 2017

Dave Cheney 3 min read

In my previous post I showed that Go maps are not reference variables, and are not passed by reference. This leaves the question, if maps are not references variables, what are they? For the impatient, the answer is: A map value is a pointer to a runtime.hmap structure. If you’re not satisfied with this explanation, read on. What […]

goprogrammingmaps

29 Apr 2017

Dave Cheney 2 min read

My post on pointers provoked a lot of debate about maps and pass by reference semantics. This post is a response to those debates. To be clear, Go does not have reference variables, so Go does not have pass-by-reference function call semantics. What is a reference variable? In languages like C++ you can declare an alias, […]

goprogrammingpass by referencepass by valuereferences

26 Apr 2017

Dave Cheney 3 min read

This post is for programmers coming to Go who are unfamiliar with the idea of pointers or a pointer type in Go. What is a pointer? Simply put, a pointer is a value which points to the address of another. This is the textbook explanation, but if you’re coming from a language that doesn’t let […]

goprogrammingpointers

11 Apr 2017

Dave Cheney 2 min read

Full disclosure: my employer makes a Slack alternative. All my concerns about the use of Slack type chat services apply equally to its competitors, including my employer’s. I’ve tweeted a few times about my frustration with the movement of open source projects from open, asynchronous, communication tools like forums, mailing lists, and issue trackers, to […]

programmingsmall ideas

9 Apr 2017

Dave Cheney 1 min read

This weekend I polished up my Arduino Day project and published it to GitHub for Retrochallenge 2017/04. Introducing Arduino6502 https://github.com/davecheney/arduino6502 The repository contains an Arduino sketch that can be loaded on Arduino Mega boards (Arduino Uno’s can be accommodated by lowering the RAMSIZE value). The sketch includes ROM images for AppleSoft Lite and Krusader symbolic […]

hardware hackingretrochallengerc2017 04

5 Apr 2017

Dave Cheney 1 min read

This is my late entry for the 2017/04 retrochallenge. Notwithstanding my 2015 failure to launch, I plan to work on Arduino based emulators for various 6502 computers. A few years ago I built an Arduino shield to host a real 6502 using the Arduino as RAM, PIA, and glue logic. To some extent the software that this project ran […]

retrochallengerc2017 04

20 Mar 2017

Dave Cheney 3 min read

A few weeks ago I was asked by a friend, “why should I care about Go”? They knew that I was passionate about Go, but wanted to know why I thought other people should care. This article contains three salient reasons why I think Go is an important programming language. Safety As individuals, you and I may be […]

goprogrammingconcurrencyproductivitysecurity

12 Feb 2017

Dave Cheney 8 min read

As an organiser of a large programming conference and a speaker who’s pitched talk ideas to many conferences, I’ve been on both sides of the selection process. Last month I published a piece on writing a proposal for GopherCon. I wanted to revisit that post in the form of more general advice to give some insight into […]

small ideaspublic speaking

9 Feb 2017

Dave Cheney 2 min read

In April and May I’ll be speaking at GopherChina and GopherCon Singapore, respectively. This post is a teaser for the talks that were selected by the organisers. If you’re in the area, I hope you’ll come and hear me speak. GopherChina GopherChina is the third event in this conference series and this year will return to Shanghai. I was […]

goprogramminggopherchinagophercon sg

25 Jan 2017

Dave Cheney 2 min read

In my previous post I suggested that the best way to break the compile time coupling between the logger and the loggee was passing in a logger interface when constructing each major type in your program. The suggestion has been floated several times that logging is context specific, so maybe a logger can be passed around via […]

goprogrammingdesignlogging

23 Jan 2017

Dave Cheney 2 min read

This post is a spin-off from various conversations around improving (I’m trying not to say standardising, otherwise I’ll have to link to XKCD) the way logging is performed in Go projects. Consider this familiar pattern for establishing a package level log variable. package foo import “mylogger” var log = mylogger.GetLogger(“github.com/project/foo”) What’s wrong with this pattern? The first problem […]

goprogrammingdesignlogging

22 Dec 2016

Dave Cheney 1 min read

In Go, goroutines are cheap to create and efficient to schedule. The Go runtime has been written for programs with tens of thousands of goroutines as the norm, hundreds of thousands are not unexpected. But goroutines do have a finite cost in terms of memory footprint; you cannot create an infinite number of them. Every time you […]

goprogramminggoroutinesleak

20 Dec 2016

Dave Cheney 4 min read

This is a short blog post about my thoughts on using Go in anger through several workplaces, as a developer and an advocate. What is $GOPATH? Back when Go was first announced we used Makefiles to compile Go code. These Makefiles referenced some shared logic stored in the Go distribution. This is where $GOROOT comes from. […]

goprogrammingsmall ideasdependency managementgopath

15 Dec 2016

Dave Cheney 1 min read

This post is about declaration scopes and shadowing in Go. package main import "fmt" func f(x int) { for x := 0; x < 10; x++ { fmt.Println(x) } } var x int func main() { var x = 200 f(x) } This program declares x four times. All four are different variables because they exist […]

goprogrammingscope

3 Dec 2016

Dave Cheney 1 min read

This is a short blog post to reference the slides from my builderscon 2016 presentation. I had a great time at buildercon, the talks were varied and engaging from a wide selection of Japanese makers. I’m grateful to the builderscon organisers for accepting my talk and inviting me to present at the inaugural builderscon conference in […]

hardware hackingprogrammingarduinobuildersconpdp11

19 Nov 2016

Dave Cheney 7 min read

This is a progress report on the Go toolchain improvements during the 1.8 development cycle. Now we’re well into November, the 1.8 development window is closing fast on the few remaining in fly change lists, with the remainder being told to wait until the 1.9 development season opens when Go 1.8 ships in February 2017. […]

goprogrammingarmarm64performance

12 Nov 2016

Dave Cheney 14 min read

This is the text of my dotGo 2016 presentation. A recording and slide deck are also available. Hello, welcome to dotGo. Two years ago I stood on a stage, not unlike this one, and told you my opinion for how configuration options should be handled in Go. The cornerstone of my presentation was Rob Pike’s blog post, […]

gosmall ideas

24 Oct 2016

Dave Cheney 4 min read

Just so we’re clear, this post is a thought experiment, not any form of commitment to deliver Go 2.0 in any time frame. While I personally believe there will be a Go 2.0 in the future, I’m in no position to influence its creation; hence, this post is mere speculation. Why introduce a new major version […]

goprogrammingsmall ideasgo2.0

30 Sept 2016

Dave Cheney 4 min read

The recent total war bombardment of Brian Krebs’ site, and the subsequent allegation that the traffic emanated from compromised home routers, cameras, baby monitors, doorbells, thermostats, and whatnot, got me thinking. Prolexic said the 665 Gbps attack that hit my site tonight is almost twice the size of the largest attack they've seen previously. — […]

small ideasinternet of shitiotsecurity

17 Sept 2016

Dave Cheney 5 min read

Sunday September the 18th marks a month since the Go 1.8 cycle opened officially. I’m passionate about the performance of Go programs, and of the compiler itself. This post is a brief look at the state of play, roughly 1/2 way into the development cycle for Go 1.81. Note: these results are of course preliminary […]

goprogrammingperformance

20 Aug 2016

Dave Cheney 16 min read

This post is based on the text of my GolangUK keynote delivered on the 18th of August 2016. A recording of the talk is available on YouTube. This post has been translated into Simplified Chinese by Haohao Tian. Thanks Haohao! This post has been translated to Russian by Artem Zinoviev. Thanks Artem! How many Go programmers […]

goprogramminggolanguksolid

30 Jun 2016

Dave Cheney 2 min read

Long time readers of this blog will know that when I’m not shilling for the Go language, my hobbies include electronics and retro computing. For me, projects like James Newman’s Megaprocessor, a computer built entirely from discrete components, is about as good as it gets. James has recently finished construction of the Megaprocessor and has started […]

hardware hackinghistoryfundamentals

26 Jun 2016

24 Jun 2016

Dave Cheney 3 min read

What do we want? Version management for Go packages! When do we want it? Yesterday! What does everyone want? We want our Go build tool of choice to fetch the latest stable version when you start using the package in your project. We want them to grab security updates and bug fixes automatically, but not upgrade […]

goprogrammingdependency management

21 Jun 2016

Dave Cheney 1 min read

This is a short post to illustrate how I use the inotifywait command as a cheap and cheerful way to run my tests automatically on save. Note: inotify is only available on linux, sorry OS X users. Step 1. Install inotify-tools On Debian/Ubuntu, inotifywait and friends live in the inotify-tools package. % sudo apt-get install […]

programming

12 Jun 2016

Dave Cheney 5 min read

A few months ago I gave a presentation on my philosophy for error handling. In the talk I introduced a small errors package designed to support the ideas presented in the talk. This post is an update to my previous blog post which reflects the changes in the errors package as I’ve put it into service […]

goprogrammingerror handlingerrorsstacktrace

10 May 2016

Dave Cheney 1 min read

This is a quick post to describe how you can use test fixtures, data files on disk, with the Go testing package. Using fixtures with the Go testing package is quite straight forward because of two convenience features built into the go tool. First, when you run go test, for each package in scope, the […]

goprogrammingfixturestesting

26 Apr 2016

Dave Cheney 11 min read

This post is an extract from my presentation at the recent GoCon spring conference in Tokyo, Japan. Errors are just values I’ve spent a lot of time thinking about the best way to handle errors in Go programs. I really wanted there to be a single way to do error handling, something that we could teach all […]

goprogrammingerror handlingerrors

11 Apr 2016

Dave Cheney 1 min read

What is the value of test driven development? Is the value writing tests at the same time as you write the code? Sure, I like that property. It means that at any time you’re one control-Z away from your tests passing; either revert your test change, or fix the code so the test pass. The nice property of this method…

programmingsmall ideastddtesting

7 Apr 2016

Dave Cheney 2 min read

This is a thought experiment about sentinel error values in Go. Sentinel errors are bad, they introduce strong source and run time coupling, but are sometimes necessary. io.EOF is one of these sentinel values. Ideally a sentinel value should behave as a constant, that is it should be immutable and fungible. The first problem is […]

goprogrammingerror handlingerrors

2 Apr 2016

Dave Cheney 3 min read

This is a progress report on the Go toolchain improvements during the 1.7 development cycle. All measurements were taken using a Thinkpad x220, Core i5-2520M, running Ubuntu 14.04 linux. Faster compilation Since Go 1.5, when the compiler itself was translated from C to Go, compile times are slower than they used to be. Everyone knows it, nobody […]

goprogrammingcompilerperformance

30 Mar 2016

Dave Cheney 1 min read

When you think about it, threads are a strange abstraction. From the programmer’s point of view, threads are great. It’s as if you can create virtual CPUs, on the fly, and the operating system will take care of simulating these virtual CPUs on top of real ones. But on an implementation level, what is a […]

programmingsmall ideasconcurrencygoroutinesthreads

25 Mar 2016

Dave Cheney 3 min read

In December 2014 the Go project moved from Google Code to GitHub. Along with the move to GitHub, the Go project moved from Mercurial to Git, which necessitated a move away from Rietveld to Gerrit for code review. A healthy open source project lives and dies by its contributors. People come and people go as time, circumstance, their […]

gocontributingopen source

24 Mar 2016

Dave Cheney 1 min read

The must be willing to relocate to San Francisco meme has been doing the rounds on Twitter to great effect. The best jokes have a grain of truth to them. I think it is absurd to expect to draw on an infinite supply of debt burdened twenty somethings to relocate to the hottest real estate market on the planet. A…

small ideas

18 Mar 2016

Dave Cheney 2 min read

This post is a continuation of a suggestion I made on twitter a few days ago. In Go, for any type T, there exists a type *T which is the result of an expression that takes the address of a variable of type T1. For example: type T struct { a int; b bool } […]

goprogrammingdesignmethodspointers

12 Mar 2016

Dave Cheney 2 min read

Occasionally I am asked for advice on how to get started contributing to an Open Source project. I thought it may be useful to write down my suggestions. These points were written in the context of the Go programming language, but I think this advice is applicable to the majority of modern Open Source projects. […]

programmingcontributinggetting startedopen source

29 Feb 2016

Dave Cheney 2 min read

At $DAYJOB I work on a very large Go application; hundreds and hundreds of packages. Recently I’ve been trying to untangle some code that has inadvertently grown huge trunks of dependencies. I suspect this is what is causing the time taken to link our tests to become the subject of ridicule. I’ve tried previously to […]

goprogrammingdependencies

6 Feb 2016

Dave Cheney 2 min read

Sandi Metz’s post on abstraction struck a chord with me recently. I was working with a piece of code which looked like this (in pseudo code): func Start() { const filename = "..." createOuputFile(filename) go run(filename) } It turned out that createOutputFile was written in an obscure way which first caused me to look at […]

goprogrammingabstractiondesign

18 Jan 2016

Dave Cheney 7 min read

To steal a quote from JWZ, Some people, when confronted with a problem, think “I know, I’ll use cgo.” Now they have two problems. Recently the use of cgo came up on the Gophers’ slack channel and I voiced my concerns that using cgo, especially on a project that is intended to showcase Go inside […]

goprogrammingcgo

7 Dec 2015

Dave Cheney 2 min read

Panic messages from unexpected program crashes are often reported on the Go issue tracker. An overwhelming number of these panics are caused by data races, and an overwhelming number of those reports centre around Go’s built in map type. unexpected fault address 0x0 fatal error: fault [signal 0x7 code=0x80 addr=0x0 pc=0x40873b] goroutine 97699 [running]: runtime.throw(0x17f5cc0, 0x5) […]

goprogrammingdata racerace detector

Dave Cheney 2 min read

What does the computing landscape look like in a decade ? In a word, bifurcated. At the individual level there will be range of battery powered devices; watches, mobile phones, tablets with removable keyboards, and those without. They will be numerous, at a wide range of price points, allowing them to be dedicated to the […]

programmingsmall ideas

29 Nov 2015

Dave Cheney 7 min read

Introduction The Go runtime, in addition to providing the usual services of garbage collection, goroutine scheduling, timers, network polling and so forth, contains facilities to enable extra debugging output and even alter the behaviour of the runtime itself. These facilities are controlled by environment variables passed to the Go program. This post describes the function of […]

goprogramminggodebuggogcgomaxprocs

18 Nov 2015

Dave Cheney 1 min read

The following program contains a data race package main import ( "fmt" "time" ) type RPC struct { result int done chan struct{} } func (rpc *RPC) compute() { time.Sleep(time.Second) // strenuous computation intensifies rpc.result = 42 close(rpc.done) } func (RPC) version() int { return 1 // never going to need to change this } […]

goprogrammingpop quiz

14 Nov 2015

Dave Cheney 12 min read

In October this year I had the privilege of speaking at the GothamGo conference in New York City. As I talk quite softly, and there were a few problems with the recording, I decided to write up my slide notes and present them here. If you want to see the video of this presentation, you […]

gohistorygothamgo

5 Nov 2015

Dave Cheney 5 min read

This is a post inspired by a thread that Nate Finch started on the Go Forum. This post focuses on Go, but if you can see your way past that, I think the ideas presented here are widely applicable. Why no love ? Go’s log package doesn’t have leveled logs, you have to manually add prefixes like […]

goprogrammingsmall ideasdesignlogging

29 Oct 2015

Dave Cheney 2 min read

Last night at the Sydney Go Users’ meetup, Jason Buberel, product manager for the Go project, gave an excellent presentation on a product manager’s perspective on the Go project. As part of his presentation, Buberel broke down the marketplace for a programming language into seven segments. As a thought experiment, I’ve taken Buberel’s market segments […]

programmingsmall ideascompetition

15 Oct 2015

Dave Cheney 3 min read

This post is a continuation of my previous post on bootstrapping Go 1.5 on the Raspberry Pi. Now that Go 1.5 is written entirely in Go there is a bootstrapping problem — you need Go to build Go. For most people running Windows, Mac or Linux, this isn’t a big issue as the Go project […]

goprogrammingarm64bootstrappingppc64

9 Oct 2015

Dave Cheney 8 min read

We all know that the empty struct consumes no storage, right ? Here is a curious case where this turns out to not be true. This is a story about trying to speed up the Go compiler. Since Go 1.5 we’ve had the great concurrent GC, which reduces the cost of garbage collection, but no […]

goprogrammingalignmentpadding

4 Sept 2015

Dave Cheney 2 min read

This is a short post to describe my recommended method for building Go on the Raspberry Pi. This method has been tested on the Raspberry Pi 2 Model B (900Mhz, 1Gb ram) and the older Raspberry Pi 1 Model B+ (700Mhz, 512Mb ram). This method will build Go 1.5 into you home directory, $HOME/go. As […]

goprogrammingraspberrypi

22 Aug 2015

Dave Cheney 3 min read

Now that Go 1.5 is out, lots of gophers are excited to try the much improved cross compilation support. For some background on the changes to the cross compilation story you can read my previous post, or Rakyll’s excellent follow up piece. I’ll assume that you are using the binary version of Go 1.5, as distributed from […]

goprogrammingcross compilation

19 Aug 2015

Dave Cheney 1 min read

For the longest time I had this alias in my .bashrc alias gb='go install -v' as an homage to John Asmuth’s gb tool which I was very fond of way back before we had the go tool. Once gb was written, I had to remove that alias and live in a world where I used […]

goprogramminggb

8 Aug 2015

Dave Cheney 11 min read

This article is also available in Japanese, イベントループなしでのハイパフォーマンス – C10K問題へのGoの回答 This article is based on a presentation I gave earlier this year at OSCON. It has been edited for brevity and to address some of the points of feedback I received after the talk. A common refrain when talking about Go is it’s a language […]

goprogramming

2 Jul 2015

Dave Cheney 3 min read

This is a short blog post explaining why I believe that Go and Rust are not competitors. Why people think Rust and Go are competitors To explain why I think Rust and Go are not competitors, I want to to lay out the reasons why I think the question is being asked in the first place. Rust […]

goprogrammingrust

13 Jun 2015

Dave Cheney 1 min read

Today I was devastated to learn of yet another women being driven from the tech industry. This is so far from being all right it does not even register on the same scale. The tech industry is a sick, male dominated, misogynistic, flaccid void that continues to permit weak, small, frightened men to abuse and […]

uncategorized

8 Jun 2015

Dave Cheney 11 min read

A few months ago I introduced gb as a proof of concept to the audience at GDG Berlin. Since then, together with a small band of contributors and an enthusiastic cabal of early adopters, gb has moved from proof of concept, written mostly on trains during a trip through Europe, to something approaching a usable […]

goprogramminggbreproducible builds

5 Jun 2015

Dave Cheney 3 min read

bytes.Buffer is a tremendously useful type, but it’s a bit large1. % sizeof -p bytes Buffer Buffer 112 … and that is just the overhead, we haven’t put any data into the buffer yet. This Friday’s2 challenge is to write a replacement for bytes.Buffer that implements io.ReadWriter and allows the caller to discover the length and capacity of the […]

goprogramminguseless trivia

30 May 2015

Dave Cheney 2 min read

I’m going to be speaking at OSCON this year about Go performance. The title of the talk is High performance servers without the event loop and will focus on the features of the language and its runtime that transparently let Go programmers write high performance network servers without resorting to event loops and callback spaghetti. As the […]

goprogrammingoscon

22 May 2015

Dave Cheney 2 min read

This is a quick Friday blog post to talk about a recent experience I had working on a piece Juju code that needed to capture the data being sent over a net.Conn. Most Gophers know that the net package provides a net.Pipe function which returns a pair of net.Conns representing an in memory network connection. net.Pipe […]

goprogrammingmockingreaderstesting

11 May 2015

Dave Cheney 1 min read

In April 2015 I gave a presentation to the GDG Berlin meetup group (slides, video) discussing my views on reproducible builds using the Go programming language. As part of that presentation I demonstrated a replacement build tool that I had been developing, gb. From the feedback I received after the meetup it was clear that […]

goprogramminggb

28 Mar 2015

Dave Cheney 2 min read

Update: Two months after making this post, it’s already out of date, 2015 will feature ten Go conferences. Last month, during my concluding remarks at Gophercon India, I threw out a statistic: In 2014 there were five international Go conferences. In 2015 there will be seven. Barely a month on from this statement I must […]

go

26 Mar 2015

Dave Cheney 2 min read

When I was younger, I wanted to learn to play the guitar (this was the 90’s after all). So I cracked open my piggy bank, bought a decent beginners guitar and took some lessons. I regularly bought the guitar magazines that appeared in the local newsagent and practised along to my favourite songs. I noodled […]

gosmall ideassimplicity

19 Mar 2015

Dave Cheney 1 min read

I am frequently contacted by recruiters looking for leads. This isn’t an attempt to blow my own horn, I’m sure you are also constantly pestered. What is frustrating is the recruiters who come calling for leads are universally unaware of the meetups and user groups in the local area for the role they are recruiting […]

small ideasrecruiting

15 Mar 2015

Dave Cheney 1 min read

Several decades ago, when I graduated high school and was wondering what I would do with my life I faced a choice. Should I take the now common “gap year” and travel the world, or should I enrol directly in university ? Oft quoted wisdom recommends that programmers looking to better themselves in their craft should […]

small ideas

7 Mar 2015

Dave Cheney 19 min read

This is the text of my closing keynote from Gophercon India. It has been slightly altered for readability from my original speaking notes. I am indebted to the organisers of Gophercon India for inviting me to speak, and to Canonical for giving me the time off to attend the conference. If you want to see me […]

goprogrammingsmall ideasgophercon india

2 Mar 2015

Dave Cheney 4 min read

Introduction Cross compilation is one of Go’s headline features. I’ve written about it a few times, and others have taken this work and built better tooling around it. This morning Russ Cox committed this change which resolved the last issue in making cross compilation simpler and more accessible for all Gophers. When Go 1.5 ships […]

goprogrammingcross compilation

26 Feb 2015

Dave Cheney 1 min read

I have updated my unofficial ARM tarball distributions page with prebuilt Go 1.4.2 tarballs. You can find them by following the link in the main header of this page. As these were the first tarballs produced since the move to git, please let me know if you encounter any issues.

goprogramming

25 Feb 2015

Dave Cheney 1 min read

Over the last year I have had the privilege of travelling to meet Go communities in Japan, Korea and India. In every instance I have met experienced, passionate, pragmatic programmers ready to accept Go for what it can do for them. At the same time the message from each of these communities was the same; […]

goprogrammingsmall ideas

17 Feb 2015

Dave Cheney 7 min read

A friend recently asked me for some advice in preparing a talk for an upcoming conference. I ended up writing way more than they asked for. If you are a Nerd like me, I hope you find some of this advice helpful. Preparing the talk Read before you write Of course you should do your research […]

small ideas

13 Feb 2015

Dave Cheney 1 min read

This is a short post to recognise the incredible contribution Alex Brainman has made to the Go project. Alex was responsible for the port of Go to Windows way back before Go 1 was even released. Since that time he has virtually single-handedly supported Go and Go users on Windows. It’s no wonder that he is […]

go

25 Jan 2015

Dave Cheney 5 min read

In my previous post, I doubled down on my claim that Go’s error handling strategy is, on balance, the best. In this post, I wanted to take this a bit further, and prove that multiple returns and error values are the best, When I say best, I obviously mean, of the set of choices available […]

goprogrammingerrorsexceptionsmonads

31 Dec 2014

Dave Cheney 2 min read

This project was featured on Hackaday and the Atmel blog. For the next step in my Apple 1 replica project I decided I wanted to replace the Arduino Mega board with a bare Atmega MPU with the goal of producing a two chip solution — just the Atmel and the 6502, no glue logic or external support […]

hardware hackingarduinoatmega1284p

26 Dec 2014

Dave Cheney 5 min read

Woot! This project was featured on Hackaday. No Apple 1 under the tree on Christmas Day ? Never mind, with a 6502 and an Arduino Mega 2560 you can make your own. The Apple 1 was essentially a 6502 computer with 4k of RAM and 256 bytes of ROM. The inclusion of a 6821 PIA and a […]

hardware hackingappleapple 1apple onearduino

23 Dec 2014

Dave Cheney 2 min read

The common contract for functions which return a value of the interface type error, is the caller should not presume anything about the state of the other values returned from that call without first checking the error. In the majority of cases, error values returned from functions should be opaque to the caller. That is […]

goprogrammingerrorsinterfaces

13 Dec 2014

11 Dec 2014

Dave Cheney 1 min read

In this program, the size of variables of type x and y in memory varies by platform. package main func main() { const n = 4 type x [n]uint type y [n]int } By changing only one line can you ensure that variables of type x, and y always consume 16 bytes on all platforms […]

goprogramminguseless trivia

5 Dec 2014

Dave Cheney 1 min read

It’s a little unfair to announce winners in some kind of order as I did post the quiz at an unfriendly hour of the day for most of the planet. With that said, Tim and William came up with a great map based solution at roughly the same time. You’ll have to split the winnings […]

gouseless trivia

Dave Cheney 1 min read

This program is incorrect package main import "fmt" func f(a, b int) { var min = 0 fmt.Printf("The min of %d and %d is %d\n", a, b, min) } func main() { f(9000, 314) } By adding only one line can you make it print the correct answer ? The code must continue to be […]

gouseless trivia

1 Dec 2014

Dave Cheney 1 min read

After lurking on the fringes of the hobbyist electronic and retrocomputing communities for a few years I’ve decided to take the plunge and join the RC2015/01 retrochallenge. The task I have assigned myself is to revive this 1981 vintage revision 7 Apple II motherboard which I discovered in a box of parts while visiting my […]

hardware hackingretrochallengerc2015 01

30 Nov 2014

Dave Cheney 6 min read

The question of how to set up a new Go project appears commonly on the golang-nuts mailing list. Normally the advice for how to structure Go code centres around “read the standard library”, but the standard library is not a great deal of use to newcomers in the respect as: You don’t go get packages […]

goprogrammingrepository layout

21 Nov 2014

Dave Cheney 5 min read

Juju is a pretty large project. Some of our core packages have large complex dependency graphs and this is undesirable because the packages which import those core packages inherit these dependencies raising the spectre of an inadvertent import loop. Reducing the coupling between our core packages has been a side project for some time for me. […]

goprogrammingdependency managementvisualisation

3 Nov 2014

Dave Cheney 2 min read

Revisiting my post about error handling and exceptions, written well before Go hit 1.0, I’m pleased that it stands the test of time. Java has comprehensively demonstrated that checked exceptions (actually having both checked and unchecked exceptions) has been a disaster for the evolution of the language. Checked exceptions have placed a suffocating yoke of backward compatibility on […]

goprogrammingerror handlingexceptions

26 Oct 2014

Dave Cheney 1 min read

A topic that has weighed on my mind recently is the dichotomy of frameworks vs. libraries in the Go community. Is the prevailing stance against complex frameworks a rejection of this purported labour saving automation, or an enlightened position that has weighed the pro’s and cons and found the costs of a framework based approached outweighs the benefits ? […]

goprogrammingframeworks

22 Oct 2014

Dave Cheney 2 min read

As part of preparing for my dotGo talk I updated a few of my packages to use the functional options pattern. I only had time to show one of those packages on stage, pkg/term. This is a post about one that was left on the cutting room floor. Last year I wrote a simple package […]

goprogrammingfunctional options

16 Oct 2014

Dave Cheney 9 min read

What follows is the text of my presentation, Functional options for friendly APIs that I gave at dotGo this year. It has been edited slightly for readability. I want to thank Kelsey Hightower, Bill Kennedy, Jeremy Saenz, and Brian Ketelsen, for their assistance in preparing this talk. I want to begin my talk with a […]

goprogrammingdotgofunctional options

3 Oct 2014

Dave Cheney 1 min read

When initialising a variable with a composite literal, Go requires that each line of the composite literal end with a comma, even the last line of your declaration. This is the result of the semicolon rule. Although possibly an unintended consequence, this means that when proposing a one line change, it really is a one line change. The […]

goprogramming

28 Sept 2014

Dave Cheney 1 min read

Build tags are part of the conditional compilation system provided by the go tool. This is a quick post to discuss using build tags to selectively enable debug printing in a package. This afternoon I merged a contribution to pkg/sftp which improved the packet encoding performance but introduced a bug where some packet types were incorrectly encoded. % […]

goprogrammingdebugging

14 Sept 2014

Dave Cheney 3 min read

During my day job I’ve been working on re-factoring some the internals of Juju to reverse the trend of a growing number of dependencies in our core packages. In this post I’ll show how I used go list to help me in this task. The basics Let’s start with the basics of go list. The default invocation of go […]

gogo list

13 Sept 2014

Dave Cheney 1 min read

Here is a short recipe I use for installing multiple versions of Go from source. In this example I’m going to install the release (currently Go 1.3.1) and trunk versions of Go. Step 1. Checkout Checkout two copies of the Go source code into independent paths. % hg clone https://code.google.com/p/go -r release $HOME/go.release % hg […]

go

1 Sept 2014

Dave Cheney 1 min read

The start of September brings a close to the Go 1.4 merge window. From now until the release in December, only bug fixes and tweaks will be accepted. A major piece of work that landed in Go 1.4 cycle was the rewrite of parts of the Go runtime from C to Go. What may not […]

go

17 Aug 2014

Dave Cheney 3 min read

This is a post about Go’s built in make and new functions. As Rob Pike noted at Gophercon this year, Go has many ways of initialising variables. Among them is the ability to take the address of a struct literal which leads to serveral ways to do the same thing. s := &SomeStruct{} v := SomeStruct{} […]

goprogrammingmakenew

3 Aug 2014

Dave Cheney 4 min read

This post is about Tinyterm, a silly hack that I presented as a lightning talk at last month’s Sydney Go User group 1. You can find the original slides online at talks.golang.org. This talk is about a experiment to see if I could drive I2C devices from Go through my laptop’s VGA port. It was […]

gohardware hackingprogramminghd44780i2c

13 Jul 2014

Dave Cheney 3 min read

A few months ago I upgraded the hardware my avr11 project ran on from the atmega2560 8bit micro to the SAM3x based Arduino Due. In doing so I lost access to the excellent QuadRAM memory expansion board, and had to find another solution for accessing the micro SD card. For the moment, I’ve decided to go […]

hardware hackingardunioavr11duespi

11 Jul 2014

Dave Cheney 3 min read

Update this post is also available in Japanese. This is a post about an experimental tool that I have been working on. gcvis is a simple way of visualising the operation of the garbage collector within a Go process. Here is a screenshot of it in operation. The rest of this article explores how gcvis […]

goprogramminggcgcvisperformance

8 Jul 2014

28 Jun 2014

Dave Cheney 1 min read

Like all children who grew up in the 80’s, I was, and still am a huge fan of Ghostbusters. While recently re watching Ivan Reitman’s homage to New York, I spotted something which has gone unnoticed on the IMDB trivia page. Shortly after being evicted from the University, Ray Stantz (Aykroyd) and Peter Venkman (Murray) […]

useless trivia

27 Jun 2014

Dave Cheney 3 min read

This is a post about data races. The code for this post lives on Github, github.com/davecheney/benandjerry. The example program simulates two Ice cream makers, Ben and Jerry, who greet their customers randomly. package main import "fmt" type IceCreamMaker interface { // Hello greets a customer Hello() } type Ben struct { name string } func (b *Ben) […]

goprogrammingdata racerace detector

22 Jun 2014

Dave Cheney 1 min read

A few days ago, after reading yet another article on the critical importance of only hiring the best people — yet being unable to offer any concrete suggestions on how to do this, save slavishly repeating the “best people” homily — I posted the following https://twitter.com/davecheney/status/479126596545036288 I find twitter to be a hopeless medium for […]

small ideasrecruiting

7 Jun 2014

Dave Cheney 13 min read

Anthony Starks has remixed my original Google Present based slides using his fantastic Deck presentation tool. You can check out his remix over on his blog, mindchunk.blogspot.com.au/2014/06/remixing-with-deck. I was recently invited to give a talk at Gocon, a fantastic Go conference held semi-annually in Tokyo, Japan. Gocon 2014 was an entirely community-run one day event combining […]

goprogramminggoconperformance

4 Jun 2014

Dave Cheney 1 min read

For packages go build builds your package then discards the results. go install builds then installs the package in your $GOPATH/pkg directory. For commands go build builds the command and leaves the result the current working directory. go install builds the command in a temporary directory then moves it to $GOPATH/bin. If you liked this […]

goprogramming

24 May 2014

Dave Cheney 1 min read

Go has several ways to declare a variable. Possibly there are more ways than are strictly required but with the Go 1 contract in effect it’s not going to change. This short post gives examples of how I decide which variable declaration syntax to use. These are just suggestions, they make sense to me, but […]

goprogramminguseless triviatop tip

22 May 2014

Dave Cheney 5 min read

Go obtains much of its compilation speed from the Plan 9 compiler, of which it is a direct descendant. The Plan 9 toolchain deferred much of the work traditionally performed by a compiler to the linking stage and its performance was summarised in section 8 of this paper The new compilers compile quickly, load slowly, […]

goprogramminglinker speed

19 May 2014

Dave Cheney 1 min read

This is a quick post to discuss an interesting bug that was recently unearthed by go vet. The following code is a simplified reduction of a larger piece of code. In the original code the if statement was much larger, encompassing several complicated conditions, making the bug hard to spot visually. package main import "fmt" […]

goprogramming

9 May 2014

7 May 2014

Dave Cheney 1 min read

I have several projects on the hop at the moment which require control over a serial port, actually a serial port emulated over USB. So for the last few days I’ve let myself be distracted by writing yet another serial package for Go. github.com/pkg/term term is built on a lower level package, called termios which provides […]

goprogrammingarduinofirmataftdi

4 May 2014

Dave Cheney 1 min read

Now that go1.3beta1 has been released I’ve updated the autobench-next branch to track Go 1.2 vs tip (go1.3beta1). Using autobench is very simple, clone the repository and run make to produce a benchmark on your machine. % cd devel % git clone -b autobench-next https://github.com/davecheney/autobench.git % cd autobench % make You can stay up to date with […]

goprogrammingautobenchbenchmarkperformance

20 Apr 2014

Dave Cheney 2 min read

Introduction This post presents one technique for installing and using multiple versions of Go on a machine. This is a technique I use often as we have standardised on Go 1.2.1 for developing Juju, but develop on the tip of Go itself. You may find this technique useful for do comparisons between various Go versions for […]

goprogramming

29 Mar 2014

Dave Cheney 1 min read

This post is a follow up to Friday’s post on comments in Go. Keith Rarick and Nate Finch pointed out that I had neglected to include two important practical use cases. Build tags I’ve previously written about how to use // +build tags to perform conditional compilation. In light of the previous post it’s probably […]

goprogrammingbuild constraintscomments

28 Mar 2014

Dave Cheney 2 min read

This is a quick post to discuss the rules of comments in Go. To quickly recap, Go comments come in two forms // everything from the double slash to the end of line is a comment /* everything from the opening slash star, to the closing one is a comment */ As the first form […]

goprogrammingcgocomments

24 Mar 2014

Dave Cheney 4 min read

Introduction This post explores the properties of my favourite Go data type, the empty struct. The empty struct is a struct type that has no fields. Here are a few examples in named and anonymous forms type Q struct{} var q struct{} So, if an empty struct contains no fields, contains no data, what use […]

goprogrammingempty structstruct

22 Mar 2014

Dave Cheney 1 min read

It has been roughly six months since I wrote about the problems I saw with package management in Go. In the intervening months there has been lots of discussion; the issue continues to be one of the two most continually and hotly debated on the golang-nuts and go-pm mailing lists. No prizes for guessing what […]

goprogramminggo-pmpackage managementvendoring

19 Mar 2014

Dave Cheney 3 min read

Most new Go programmers quickly grasp the idea of a channel as a queue of values and are comfortable with the notion that channel operations may block when full or empty. This post explores four of the less common properties of channels: A send to a nil channel blocks forever A receive from a nil […]

goprogrammingchannels

16 Mar 2014

Dave Cheney 2 min read

This blog post was originally a comment on a Google Plus page, but apparently one cannot create a href to a comment so it was suggested I rewrite it as a blog post. Go pointers, like C pointers, are values that, uh, point to other values. This is a tremendously important concept and shouldn’t be […]

goprogrammingpointers

8 Mar 2014

Dave Cheney 1 min read

In addition to developing avr11, a software simulation of a PDP-11/40, I also wrote a Go version of the simulator. I recently had an opportunity to talk about the Go based version at the Sydney and Melbourne Go meetups. The link to the slides are Sydney Melbourne The code itself is not really ready for […]

goprogramming

16 Feb 2014

Dave Cheney 4 min read

Mea culpa In my first post I said that I believed the simulator performance was 10x slower than a real PDP-11/40, sadly it looks like that estimate was well off by at least another factor of 10. Yup, 100x slower than the machine I tried to simulate. At least. More accurate profiling After my last […]

hardware hackingarduinoavr11sam3x

30 Jan 2014

Dave Cheney 3 min read

This is a post about the performance of my avr11 simulator. Specifically about the performance improvements I’ve made since my first post, and the surprises I’ve encountered during the process. Old school profiling Because avr11 runs directly on the Atmega 2560 microcontroller, there is no simple way to measure the performance of various pieces of […]

programmingavr11profiling

25 Jan 2014

24 Jan 2014

Dave Cheney 5 min read

18 bits of core memory In Schmidt’s original javascript simulator, and my port to Go, the 128 kilowords (256 kilobytes) of memory connected to the PDP-11 is modeled using an array. This is a very common technique as most simulators execute on machines that have many more resources than the machines they impersonate. However, when I […]

hardware hackingprogrammingarduinoavr11spi

23 Jan 2014

Dave Cheney 2 min read

This post is a rant about a word. A rant about a word that had a clear meaning but has been appropriated for something wholly less meaningful. The word is of course Devops. Over the last few years, as the practice itself has grown in prominence, its description has become diluted beyond the point of recovery. […]

small ideasdevops

21 Jan 2014

Dave Cheney 1 min read

With one exception, the go command takes arguments in the form of packages. You can pass the package name(s) explicitly, eg. go test github.com/hoisie/mustache or implicitly cd $GOPATH/src/github.com/hoisie/mustache go test . By default, if no arguments are provided go test treats the current directory as a package, so in the second example, go test . […]

goprogramminggo buildgo installgo test

5 Jan 2014

Dave Cheney 2 min read

This post talks about how I connected my Raspberry Pi to a WYSE 60 terminal. Voltages The terminal speaks RS232 level, +/- 12v, but the Pi speaks 3.3v TTL levels so some sort of converter is needed to adapt the signalling levels. A logic level converter won’t work as RS232 signalling needs negative voltages as […]

hardware hackingraspberry pi

29 Dec 2013

Dave Cheney 1 min read

I enjoyed Caro’s last book, Master of the Senate, but his latest book is something really special. Over the last couple of chapters Caro has gently raised the tension by laying out the Bobby Baker scandal and the imminent deposition of Don Reynolds who’s testimony will likely fatally bind LBJ to his protégé. Meanwhile, the […]

history

28 Dec 2013

Dave Cheney 1 min read

I have updated my unofficial ARM tarball distributions page with prebuilt Go 1.2 tarballs. You can find them by following the link in the main header of this page. If you are interested in the potential performance improvements in Go 1.2, I wrote a post about it on the Gopher Academy blog as part of this year’s Go Advent […]

goprogrammingarm

4 Dec 2013

Dave Cheney 1 min read

There is an apocryphal story1 during World War Two, of a squadron of bombers leaving on a sortie. Time passes and finally a few bombers struggle back to their base, the crew shaken, but alive, their aircraft riddled with bullet holes. Shocked by their losses, the reaction by Air Force was to order the areas of the […]

small ideasuseless trivia

2 Dec 2013

Dave Cheney 1 min read

If you’re interested in the performance improvements delivered in Go 1.2, I’ve written about it as part of this years Go Advent project. You can find the post on the Gopher Academy blog, blog.gopheracademy.com/day-02-go-1.2-performance-improvements.

goprogramming

20 Nov 2013

Dave Cheney 1 min read

Over the last few weeks I had the opportunity of working with the Joyent folks on the port of Go to Solaris1. As part of this work I noted that the Joyeurs were using their rather spiffy Manta service for sharing code snippets and build logs. This made the rest of us using Pastebin services […]

goprogrammingjoyentmantasunos

19 Nov 2013

Dave Cheney 1 min read

I’ve been doing a lot of work with gccgo recently and with the upcoming release of Go 1.2 I’ve also been collecting benchmark results for that release. Presented below, using a very unscientific method, are the results of comparing the go1 benchmark results for the two compilers. Buried among that see of red are a few […]

goprogramminggccgo

15 Nov 2013

Dave Cheney 1 min read

At Canonical we’re increasingly invested in gccgo. While testing various packages built with gccgo we ran across test failures which we traced to an innocent looking piece of code. package main import "fmt" type T struct { i int } func (t *T) readInt32() int32 { t.i += 4 return 42 // not important } […]

goprogramminguseless trivia

14 Nov 2013

Dave Cheney 1 min read

In a previous post I blogged about the cover tool coming in Go 1.2 and a bash helper function I use to make the tool a little easier to use. Since then I’ve extended these helpers so I wanted to blog about the improvements. Passing arguments to the testing tool cover () { t=$(tempfile) go […]

goprogrammingcovercoverage

13 Nov 2013

Dave Cheney 1 min read

This is a brief post highlighting a curious aspect of the declaration syntax in Go. Most Go programmers know that the following of import declarations are equivalent import "fmt" import "math/big" // same as import ( "fmt" "math/big" ) The same applies to const declarations const FORTYTWO = 42 const TRUE = 1 // same […]

goprogramminguseless trivia

7 Nov 2013

Dave Cheney 1 min read

A few days ago I was working on an example program for the sftp package and found I needed to implement subcommand handling. https://twitter.com/davecheney/status/397686194462396416 The response was fantastic, no less than 12 different packages. I haven’t had the chance to review any of the packages in detail, but I wanted to list them here as […]

goprogramming

4 Nov 2013

Dave Cheney 1 min read

With the release of go1.2rc3 last week I have now merged the autobench-next branch into master in the autobench repository. Go 1.2 is not expected to bring performance improvements of the same magnitude of Go 1.1, but moderate improvements are expected due to improvements in code generation, the runtime, the garbage collector, and the standard […]

goprogrammingautobenchbenchmark

20 Oct 2013

Dave Cheney 3 min read

This is a quick post explaining how to install Ubuntu 12.04 on your Udoo Quad board (I’m sure the instructions can be easily adapted to the Dual unit as well). The Udoo folks have made available two distributions, Linaro Ubuntu 11.10 and Android 4.22. The supplied Linaro distribution is very good, running what looks like […]

hardware hackingudooudoo dualudoo quad

15 Oct 2013

Dave Cheney 5 min read

This post explains how the Go build process works using examples from Go’s standard library. The gc toolchain This article focuses on the gc toolchain. The gc toolchain takes its name for the Go compiler frontend, cmd/gc, and is mainly used to distinguish it from the gccgo toolchain. When people talk about the Go compilers, they […]

goprogrammingcompilertoolchain

12 Oct 2013

Dave Cheney 5 min read

When developing Go packages that rely on specific features of the underlying platform or processor it is often necessary to provide a specialised implementation. Go does not have a preprocessor, a macro system, or a #define declaration to control the inclusion of platform specific code. Instead a system of tags and naming convention defined in the go/build […]

gophotographybuild constraintsbuild tagsgo build

10 Oct 2013

7 Oct 2013

Dave Cheney 2 min read

Did you know that Go 1.2 will ship with a built in test coverage tool ? The tool is integrated into go test and works similarly to the profiling tool, producing an output file which is interpreted by a second command. If you have Go 1.2rc2 or tip installed, you can use this short shell […]

goprogrammingcoveragego test

22 Sept 2013

Dave Cheney 5 min read

Introduction I recently purchased a Beaglebone Black (BBB) as a replacement for a Raspberry Pi which was providing the freebsd/arm builder for the Go build dashboard. Sadly the old RPi didn’t work out. I’m hoping the BBB will be a better match, faster, and more reliable. The BBB is a substantial upgrade to the original […]

hardware hackingbeaglebonebeaglebone blackftdiserial

21 Sept 2013

Dave Cheney 1 min read

Clearly I’m biased when it comes to the popularity of Go, so here is another data point. [line_chart title=”#golang tweets per month” v_title=”tweets” width=”600px” height=”400px” scale_button=”true”] [‘Month’, ‘Tweets’], [ ‘2009-11’ , 60 ], [ ‘2009-12’ , 31 ], [ ‘2010-01’ , 14 ], [ ‘2010-02’ , 36 ], [ ‘2010-03’ , 56 ], [ ‘2010-04’ […]

go

Dave Cheney 1 min read

Go 1.2 is on target for a December release and the Go team have just cut their first release candidate. You can find the draft (no twitterverse, Go 1.2 isn’t released yet) release notes for Go 1.2 online here. I have updated my unofficial ARM tarball distributions page with prebuilt go1.2rc1 tarballs. You can find them by following the link…

goprogramminggo1.2release candidate

18 Sept 2013

9 Sept 2013

Dave Cheney 2 min read

The port of Juju to Go is a project I’ve been involved in at Canonical for some time now. The power behind Juju is charms, which are part configuration management and part reliable workflow engine. One non-conventional use of Juju is something I cooked up a while ago when traveling, a Juju charm that compiles […]

programminggccgojuju

7 Sept 2013

Dave Cheney 4 min read

It looks like Go 1.4 will remove support for Go packages containing C code (as described below, don’t confuse this with CGO), so enjoy it while it lasts. This is a short post designed to illustrate how Go package authors can write package level functions in C and call them from Go code without using […]

goprogrammingc++cgo

4 Sept 2013

Dave Cheney 2 min read

A few days ago a post entitled Autoworkers of Our Generation floated across my radar. In his post, Greg Baugues argues that as developers, we have a short term advantage, and would do well to view our lot as a temporary anomaly. In this article I’d like to engage with his post, and respond. The key […]

economyhistoryprogramming

26 Aug 2013

Dave Cheney 1 min read

Earlier this year I wrote a small harness to compare the relative performance of Go 1.0 and the then just released Go 1.1. You can read the posts about the Go 1.1 performance improvements: amd64, 386 and arm. As the Go 1.2 cycle is entering feature freeze next week, I’ve taken the opportunity to create a […]

goprogrammingbenchmarkperformance

6 Aug 2013

Dave Cheney 1 min read

Thanks to Little Bird Electronics I just picked up the recently released Cubieboard 2. For less than 90 bucks Australian you get the case, 4Gb of onboard NAND flash, a USB to serial adapter, USB to power adapter (althought you should use a real wall wart), and an adapter for the onboard SATA port which […]

gohardware hackingcubieboardcubieboard 2

8 Jul 2013

Dave Cheney 3 min read

This post is a compliment to one I wrote in August of last year, updating it for Go 1.1. Since last year tools such as goxc have appeared which go a beyond a simple shell wrapper to provide a complete build and distribution solution. Introduction Go provides excellent support for producing binaries for foreign platforms […]

goprogrammingcgocross compilationcross compile

7 Jul 2013

Dave Cheney 2 min read

This package has been superseded. Please read this blog post for more details. Introduction The Go runtime has built in support for several types of profiling that can be used to inspect the performance of your programs. A common way to leverage this support is via the testing package, but if you want to profile […]

goprogrammingbenchmarkingprofiling

2 Jul 2013

30 Jun 2013

Dave Cheney 4 min read

This post continues a series on the testing package I started a few weeks back. You can read the previous article on writing table driven tests here. You can find the code mentioned below in the https://github.com/davecheney/fib repository. Introduction The Go testing package contains a benchmarking facility that can be used to examine the performance […]

goprogrammingbenchmarktesting