---
title: "Best practices for writing high-performance Go code"
publication: "Go Weekly"
issue: 253
published_at: "2019-03-14"
canonical_url: "https://golangweekly.com/issues/253"
---

The latest Golang development news       

#253 — March 14, 2019 

[Read on the Web](https://golangweekly.com/issues/253)   

Golang Weekly 

**New:** Be sure to check out our first Go developer interview at the bottom of this issue. We spoke to Ron Evans (of [Gobot](https://gobot.io/)) about why Go is well suited for hardware and microcontroller use :-) 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/khtqbihbdvnuhsq4nfp3.jpg)](https://github.com/ztrue/tracerr)   

[Tracerr: Go Errors with Stack Trace & Source Fragments](https://github.com/ztrue/tracerr) — An interesting experiment in making Go error output more informative. [More examples here.](https://github.com/ztrue/tracerr/tree/master/examples) 

ztrue   

[The State of Caching in Go](https://blog.dgraph.io/post/caching-in-go/) — Spoiler: The results are not great. This post talks about why various cache algorithms don’t work well in Go and what they are going to do about it. 

Dgraph   [![\](https://copm.s3.amazonaws.com/bc266c57.png)](https://circleci.com/blog/designing-a-package-manager-from-the-ground-up/?utm_source=cooperpress&utm_medium=newsletter&utm_campaign=mar19&utm_content=go-newsletter) 

[Designing a Package Manager from the Ground Up - CircleCI Orbs](https://circleci.com/blog/designing-a-package-manager-from-the-ground-up/?utm_source=cooperpress&utm_medium=newsletter&utm_campaign=mar19&utm_content=go-newsletter) — CircleCI recently launched a package manager just for CI: CircleCI orbs. If you're using orbs today and want to understand how to get the most from them, or if you're thinking about designing your own package management system, this post is for you. 

CircleCI sponsor   

[Best Practices for Writing High-Performance Go Code](https://github.com/dgryski/go-perfbook) — We first linked this a year ago and while it remains an ‘in progress’ document, there’s plenty to enjoy and contributions are welcomed if you can flesh it out. 

Damian Gryski   

[Managing Go Module Deprecation](https://medium.com/@mcdonnell.myles/managing-go-module-deprecation-3f7065c44e5c) — An introduction to [modcop](https://github.com/go-tooling/modcop), a new CLI tool that inspects `go.mod` files for deprecated versions. 

Myles McDonnell   

[MongoDB Go Driver 1.0.0: The Official MongoDB Driver](https://github.com/mongodb/mongo-go-driver) — [1.0](https://github.com/mongodb/mongo-go-driver/releases/tag/v1.0.0) is finally here after a long process which began with [Considering the Community Effects of Introducing an Official MongoDB Go Driver](https://engineering.mongodb.com/post/considering-the-community-effects-of-introducing-an-official-golang-mongodb-driver) in January 2018. 

MongoDB, Inc.  

💻 Jobs  

[Senior Backend Developer (Copenhagen)](https://www.vivino.com/jobs/senior-backend-go-developer-copenhagen) — Vivino <3 Go. 99.9% of requests are served by our Go backend. We have many ongoing projects and are looking for strong developers. 

Vivino   

[Find A Job Through Vettery](https://www.vettery.com/tech?utm_source=newsletter&utm_medium=cooper-golangweekly&utm_term=tech&utm_content=grouped&utm_campaign=ad-77582) — Vettery specializes in dev roles and is completely free for job seekers. 

Vettery  

📘 Articles & Tutorials  

[Common Traps, Gotchas, and Common Mistakes for New Go Devs](http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/) 

Kyle Quest   

[An Approach to Dependency Injection in Go using Higher Order Functions](https://stein.wtf/posts/2019-03-12/inject/) 

Stein Fletcher   

[A Brief Introduction to gRPC in Go](https://blog.lelonek.me/a-brief-introduction-to-grpc-in-go-e66e596fe244) — A quick tutorial that touches all the main bits of creating a gRPC client and server app with a reasonable amount of explanation. 

Kamil Lelonek   

[📈Data-Driven Guide to Engineering Leadership](https://www.gitprime.com/resources-data-driven-engineering-metrics/?utm_source=gonl&utm_medium=email-nl&utm_campaign=gonl%28q1%29) — Get actionable insights from 7 million commits and 85,000+ engineers, to increase your software teams velocity.[Free Guide.](https://www.gitprime.com/resources-data-driven-engineering-metrics/?utm_source=gowk&utm_medium=email-nl&utm_campaign=gowk%28q1) 

GitPrime sponsor   

[How Goroutines Work in TinyGo](https://aykevl.nl/2019/02/tinygo-goroutines) — [TinyGo](https://github.com/tinygo-org/tinygo) (a microcontroller-aimed compiler) has to take a different approach to the standard Go runtime. 

Ayke van Laëthem   

[The Ups of Downs of Porting 50k Lines of C++ to Go](https://togototo.wordpress.com/2015/03/07/fulfilling-a-pikedream-the-ups-of-downs-of-porting-50k-lines-of-c-to-go/) — An old story that’s doing the rounds again :-) _“In business terms, the project was a success,”_ but… _“I feel the outcome was suboptimal, in the sense that I wrote two to three times as much code as would have been needed in a language with parametric polymorphism.”_ 

logicchains   

[Rewriting the Sharding Layer of Uber’s Schemaless Datastore](https://eng.uber.com/schemaless-rewrite/) — How Uber rewrote and migrated their fleet of worker nodes from Python to Go without disrupting active service. 

Jesper Lindstrøm Nielsen and Anders Johnsen (Uber)   

[Using Go as the Infrastructure Language at NodeSource](https://nodesource.com/blog/using-go-infrastructure-language) — A brief enumeration of the benefits Nodesource gained with Go which could probably apply to your infrastructure, too. 

NodeSource  

🔧 Tools & Code 

[![\](https://res.cloudinary.com/cpress/image/upload/w_1280,e_sharpen:60/rfqjfqsf3c9yl2lsaqe9.jpg)](https://github.com/mattes/go-asciibot)  

[go-asciibot: An ASCII Robot Generator](https://github.com/mattes/go-asciibot) — More cute than useful, perhaps. 

Matthias Kadenbach   

[BigQueue: An Embedded, Fast, Persistent Queue in Pure Go](https://github.com/grandecola/bigqueue) — Uses memory mapped files under the hood. Linux, Darwin (macOS) and BSD-only for now. 

grandecola   

[Slim: Space-Efficient Data Structures for Go](https://github.com/openacid/slim) — An attempt at creating a library of ‘surprisingly space-efficient’ data types, though it’s just a trie structure for now. 

openacid   

[Introducing Kraken, an Open Source Peer-to-Peer Docker Registry](https://eng.uber.com/introducing-kraken/) — Yes, it’s built in Go! [GitHub repo.](https://github.com/uber/kraken) 

Cody Gibb, Evelyn Liu, and Yiran Wang (Uber Engineering)   

[go-tflite: Go Binding for TensorFlow Lite](https://github.com/mattn/go-tflite) — Very early days for this. 

Yasuhrio Matsumoto   

[Go Inside a Big Nerd Ranch Bootcamp: Free Online Session 4/24](https://attendee.gotowebinar.com/rt/6844316241493088514) 

Big Nerd Ranch sponsor   

[Pion WebRTC: A Pure Go Implementation of The WebRTC Native API](https://github.com/pions/webrtc) 

Sean DuBois   

[go-bsdiff: Pure Go `bsdiff` and `bspatch` Libraries and CLI Tools](https://github.com/gabstv/go-bsdiff) — For binary patching and diffing. 

Gabriel Ochsenhofer   

[Weaver: A Modern HTTP Reverse Proxy with Dynamic Sharding Strategies](https://github.com/gojektech/weaver) 

GO-JEK Tech        ![Ron Evans](https://res.cloudinary.com/cpress/image/upload/r_max/f23zp218zjvay5nalxjd.png) 

💬 A Q&A with…
Ron Evans
of the TinyGo, Gobot and GoCV projects  

Ron Evans is a Go developer who's best known for his work on [Gobot](https://gobot.io/), a popular library for controlling robotics/IoT devices from Go, and [GoCV](https://gocv.io/), a way to use OpenCV from Go. 

He has recently become involved with the [TinyGo](https://github.com/tinygo-org/tinygo) project, an effort to build a Go compiler that can suitably target small scale devices, such as microcontrollers and popular microcontroller boards, and WebAssembly. We caught up with him to ask a few questions about this work. 

You're well known for your work on [Gobot](https://gobot.io/). What got you into working with hardware with Go? 

I've been using open source software/hardware like Arduino for quite a while, but I got serious in around 2009 with [a series of Ruby powered blimps](https://www.youtube.com/watch?v=obnJhzMOB7A). When I discovered Go, the minimalism of the language and the way concurrency is treated as a first-class construct were appealing, and with Go being a compiled language it seemed a better fit for embedded Linux where resources are more limited. 

What inspired your work on [TinyGo](https://github.com/tinygo-org/tinygo)? 

I discovered the project last year (probably from your newsletter!) and it excited me because executing Go directly on microcontrollers seemed the last place that Go code couldn't run. I contacted the project founder [Ayke Van Laatham](https://twitter.com/aykevl) and started to contribute. TinyGo has evolved quickly from an interesting experiment into a real "thing" and we're treating it that way with good development and governance practices. Contributors welcome (particularly on areas around [our pain points with Go](https://github.com/tinygo-org/tinygo/wiki/Go-pain-points))! 

Why do you feel Go is particularly well suited for low level working with hardware? 

We're seeing high-level interpreted languages running on microcontrollers like Python and JavaScript, so it certainly seemed possible as Go is a true compiler, and the language itself is very minimal. The big leap that Ayke made was combining the Go compiler libraries with the LLVM compiler backend. The result of this is such highly optimized and fast code, that one of our demos is running a Go program on an 8-bit processor with 8K of RAM.   

Ron Evans is a technologist for hire at [The Hybrid Group.](http://hybridgroup.com/)          

Curated by [Glenn Goodrich](https://twitter.com/ruprict) and [Peter Cooper](https://twitter.com/peterc) 

[Change your email address](https://golangweekly.com/edit_subscription/*|UID|*) or[Stop getting this newsletter](https://golangweekly.com/leave/*|UID|*) 

© Cooper Press Ltd · Fairfield Enterprise Centre, Louth, LN11 0LS, United Kingdom
