The Best Go Content on the Internet


Property Based Testing

Contributed by

Useful Programs I’ll start this post with a bold but fairly uncontroversial statement: Programs that do not interact with the outside world are useless - they do nothing except consume cycles. A corollary of this is that pure functional programming is useless. Here is a (mostly) pure functional program written in Go that does absolutely nothing: package foo func incr(i int) int { return i+1 } func decr(i int) int { return i-1 } func foo() { decr(incr(0)) } While obviously there are other things that make a program useful, the most fundamental thing that makes a program useful is that it needs to interact with things outside itself.

Read more...

Custom JSON unmarshaler for a GraphQL client

Contributed by

In this post, I will tell a story of how I had to build a custom JSON unmarshaler for the needs of a GraphQL client library in Go. I’ll start with the history of how everything started, build motivation for why a custom JSON marshaler was truly needed, and then describe how it was implemented. This is going to be a long journey, so strap yourself in, and here we go!

Read more...

Repeatable and Isolated Development Environments for Go

Contributed by

One of the common criticisms of the GOPATH is that it is hard to create isolated development environments without resorting to hacks, bash scripts, multiple GOPATH settings, or other trickery. Generally, I don’t often have too many problems with GOPATH, but when I do they are frustrating and hard to figure out. An example: Your dependency manager copies deps from your GOPATH into your project’s vendor folder. But the dependency it copies is your fork, not the upstream, so the vendored package isn’t what you expected.

Read more...

Managing Dependencies, Forks, and Code Patches with Dep

Contributed by

A few months ago, we switched over to using dep to manage dependencies for Veneur. We were excited to discover that dep provided a straightforward workflow for a longstanding problem in Go development: managing forks of dependencies and contributions to upstream projects. This is a common problem with dependency management. Some tools attempt to provide workflows for managing it, and in my experience, the workflow dep has chosen is the cleanest I’ve seen.

Read more...

A Tale of Two `rand`s

Contributed by

I had always been a bit confused as to how the crypto/rand package and the math/rand package were related, or how they were expected to work (together). Is this something that everyone else already grokked, or is that just my impostor syndrome talking? Well, one day I decided to see if I could defeat my ignorance, and this blog post is the result of that investigation. The math One If you’ve ever poked around in the math/rand package, you might agree that it presents a fairly convenient API.

Read more...

Creating Your Own Bot Experience with go-sarah

Contributed by

Chat tools have been good friends of developers. On chat tools we share our thoughts, problems, solutions, jokes, and pretty much everything we do as software engineers. And when some kind of tasks can be done in the extension of daily chat conversation, chat becomes even more comfortable yet powerful place to stay. That is why I think many developers eager to customize their chat experience with bot frameworks. In this article I am going to introduce a new golang-based bot framework, go-sarah, along with its notable characteristics and components.

Read more...

Minimal Perfect Hash Functions

Contributed by

A regular hash function turns a key (a string or a number) into an integer. Most people will know them as either the cryptographic hash functions (MD5, SHA1, SHA256, etc) or their smaller non-cryptographic counterparts frequently encountered in hash tables (the map keyword in Go). Collisions, where two input values hash to the same integer, can be an annoyance in hash tables and disastrous in cryptography. Collisions can happen with any standard hash function and any number of keys.

Read more...

Automating Go development with Make

Contributed by

Make is an old tool that you can use today to help get everyone on your team on the same page, and make it easy for new contributors to your project to get started. In some cases Make can help you avoid unnecessary work! Let’s see how you can integrate Make into your development workflow. For this example, we are going to pretend our application uses protocol buffers to send data back and forth.

Read more...

Using GopherJS with gRPC-Web

Contributed by

Introduction This article will talk about how to connect a GopherJS frontend to a Go backend. If you haven’t heard about GopherJS before, it’s an open source Go-to-JavaScript transpiler, allowing us to write Go code and run it in the browser. I recommend taking a look at the official GitHub repo and Dmitri Shuralyov’s DotGo presentation Go in the browser for a deeper introduction. Writing GopherJS apps is great fun and lets us avoid writing JavaScript and all the problems associated with it.

Read more...

2017 Advent Series Call for Submissions

Contributed by

It’s November, and once again our thoughts drift towards the holidays and the awesome blog posts that arrive as gifts to you in the Gopher Academy Blog. We’d love to have YOUR contributions this year so we’re sending out our request for people to sign up for a blog post in December. It’s a fun process, and you’ll have help and support from editors along the way. If you’re ready to write a post for our Advent series, you can signup online.

Read more...