Go Challenge - 2


  • This second Go challenge is now closed.
  • There were 105 entries from 30 countries.
  • Evaluator Jeff R. Allen talks about your submitted code here and here.
  • Some of the participants blogged about their Go challenge experience: Doug Cichon and Jason Clark.
  • The winners have been announced: #1 Michael Alexander (his solution), #2 David Le Corfec (his solution), #3 William Shallum (his solution), #4 Luke Champine (his solution) and #5 Arran Walker (his solution). According to the challenge author, David Le Corfec and William Shallum were close to one another.

The April 2015 Go Challenge for developers (newbies included)

Guillaume J. Charmes: Author of the second Go Challenge

Guillaume J. Charmes The second Go Challenge author is Guillaume J. Charmes. French first, software developer second. He loves to travel and used to live in France, China, Russia, Réunion, San Francisco, Chicago and Miami. He also likes to travel between technologies and languages: He jumped from C and ASM to PHP to fall into Python to then migrate to Go with some sides of Ruby. He is coming from a low-level ASM/C background which he uses to teach as well as for web security.

He started using Go in 2009 and fell in love with its syntax and concurrency model. He joined dotCloud, Inc. where he was the only Go developer for a while. This is when they started Docker…, in Go. Arrived to Docker 1.0, he moved on to Citrix, Inc. under the sun of Florida where he helps the moving process from Ruby to Go.

Guillaume has this to say about the challenge:

“Data security is a very important matter and this challenge is a good way to dive in with the NaCl package and leverage the power of Go interfaces to implement a clean solution over the network.”

The Go Challenge 2

Can you help me secure my company’s data transmission?

Last week, our competitor released a feature that we were working on in secret. We suspect that they are spying on our network. Can you help us prevent our competitor from spying on our network?

To get started

Check out the two files main.go and main_test.go here. These files are the starting point for this challenge.


3rd April 2015: Guillaume has made 2 changes to the test files:

  • The first change is minor and concerns Window user with dual stack. He has changed the net.Listen("tcp", ":0") to net.Listen("tcp", ""). This shouldn’t change anything for most people.
  • The second is more problematic and would impact people using io.Copy. In TestReadWritePing, he has moved the w.Close() in the writing goroutine just like in the other tests.

Goal of the challenge

In order to prevent our competitor from spying on our network, we are going to write a small system that leverages NaCl to establish secure communication. NaCl is a crypto system that uses a public key for encryption and a private key for decryption.

Your goal is to implement the functions in main.go and make it pass the provided tests in main_test.go.

Steps involved

The first step is going to be able to generate the public and private keys. Next, we want to create an io.Writer and io.Reader that will allow us to automatically encrypt/decrypt our data.

Part 1

Implement the following helpers that will return our NACL Reader / Writer.

func NewSecureReader(r io.Reader, priv, pub *[32]byte) io.Reader
func NewSecureWriter(w io.Writer, priv, pub *[32]byte) io.Writer
Part 2

Now that we can encrypt/decrypt message locally, it would be interesting to do so over the network!

We are going to write a server that will exchange keys with the client in order to establish a secure communication.

In order to be able to encrypt/decrypt, we need to perform a key exchange upon connection.

For the sake of the exercise, performing the key exchange in plain text is acceptable. (In a production system, it would not be acceptable due to MITM risk!)

Unfortunately, everybody has already left for the day, so let’s write a secure echo server so we can test!

In order to test our echo server, we can do:

$> ./challenge2 -l 8080&
$> ./challenge2 8080 “hello world”
hello world

Requirements of the challenge

  • Use the latest version of Go i.e. version 1.4.2
  • Use only standard library and package(s) under golang.org/x/crypto/nacl.


  • We consider that our messages will always be smaller than 32KB
  • Most of the elements involved for encryption/decryption have fixed length
  • encoding/binary can be useful for the variable parts

Further exploration

If you have liked this challenge, you can keep programming outside the main challenge. You can:

  • create an actual user interface. It would be nice if both side had a prompt and could send more than one message at a time.
  • Handle multiple client and group chat
  • Add compression

Please keep in mind that cryptography is a complex subject matter, with many very subtle risks and mistakes to make. While it makes for a fun exercise, inventing your own crypto systems for production use is usually not a good idea and should be left to a handful of very talented people.

Challenge Rules and how to enter the Go Challenge?

By participating in this challenge, you agree to be bound by the Challenge Rules below:

  • The Challenge is open to individuals.
  • Evaluators cannot enter the challenge except under the “Just for Fun” category.
  • Each entrant shall indemnify, defend, and hold JoshSoftware Pvt. Ltd. (who has sponsored the domain and is the organizer of these challenges) harmless from any third party claims arising from or related to that entrant’s participation in the Challenge. In no event shall JoshSoftware Pvt. Ltd. be liable to an entrant for acts or omissions arising out of or related to the Challenge or that entrant’s participation in the Challenge.
  • Odds of winning depend on the number and quality of entries received.
  • All taxes, including income taxes, are the sole responsibility of the winners.
  • No prize substitution is permitted.
  • Create a zip of your Go source code and send the zip file to golangchallenge [at] gmail.com before 18th of April 2015 (6 am IST). Use this link to find the equivalent time in your city/country. No new solutions will be accepted after that. In the email mention **your full name, country of residence, twitter or GitHub id (if any) and participating under which category - Just participating Participating and exploring further Just for Fun Anonymous entry**. We are accepting anonymous submissions and will evaluate them too but then these participants are not eligible for the prizes.
  • We will give your zip file to the evaluation team.
  • We shall be publishing on this blog, a list of participant names. If you don’t want your name to appear kindly mention the same in your email.
  • You are allowed to re-submit your code if you feel it is necessary.
  • Note: Avoid sharing your code with anyone else; if your solution becomes available to the general public it might impact evaluation of your submission.
  • After the challenge is over, all submissions will be made available online on GitHub under the BSD 3-Clause License or the GNU General Public License, version 3 - GPL-3.0 unless a participant has indicated that his/her solution should not be made public before the challenge ends.

How will the challenge be evaluated?

Entries will be anonymized and evaluated by the challenge author and a team of evaluators.

  • Functioning code and a test suite that passes.
  • Code hygiene. Use gofmt, vet and lint. Review CodeReviewComments.
  • Readability. How easy is it for another programmer to grasp what your entry is doing?
  • Code structure. Do types and files have good names?
  • Reliability. Are errors properly handled?
  • Appropriate consideration given to memory and performance (nothing is unnecessarily expensive).


If you have any questions about this challenge, please join the golang-challenge channel on slack and ask your questions. This is a room for people who are going to participate in the Go Challenge. You can also send us an email at golangchallenge [at] gmail.com


Nathan Youngman had set the guidelines for evaluation for the first Go Challenge. Subsequently Dominik Honnef modified the guidelines based on his experience as an evaluator for the first challenge. Akshay Deo, Austin Riendeau, Cory LaNou, Gautam Dey, Jeff R. Allen, Jyotiska NK, Kevin Gillette and Pravin Mishra have agreed to go through all the submitted solutions of a challenge. They will comment and rank these solutions.

Best Solution

The author of the Go Challenge will decide the best five solutions. The author shall have the sole authority and discretion to select the award recipients.


The winning entries will be announced here on this blog. The winners will be sent their prizes by email/postal mail.


The author of the challenge will select 5 winners.

Here are some great prizes provided by our sponsors for the event.

Winner 1:

Winner 2:

Winner 3:

Winner 4:

Winner 5:

Anyone can a get 42% off on the price of the following eBooks from Manning Publications Co.:

Winner Interviews

After a winner wins the monthly challenge, he/she would be interviewed by Sourcegraph and the interview will be published on their blog.

The Participants

You can check out the list of participants for this challenge i.e. for April 2015.

Challenge Solutions

All the solutions submitted by the participants are available here.

The Winners


Guillaume J. Charmes has selected the winners of this challenge. They are:

Michael Alexander Winner #1 Michael Alexander is from Canberra, Australia, and currently a senior developer at HRMWeb Pty Ltd working on easyEMPLOYER.

He was introduced to BASIC at an early age and has been writing code ever since. Always keen to try new languages and technologies, he dabbled in Go when 1.0 was released in 2012 and it stuck unlike many others did for him.

His solution to the challenge.

David Le Corfec

Winner #2 - David Le Corfec started programming on Amiga in the 90’s. After Computer Science studies, he started in software development before changing to system engineering, supporting the web operations of the largest French broadcaster.

In 2013, he became interested in Go by stumbling upon groupcache, while researching caching solutions for streaming video. Shortly afterwards, Go replaced C as his favorite language, leading him to even consider a comeback to full-time programming!

His solution.

Winner 3 - William Shallum (his solution)

Winner 4 - Luke Champine (his solution)

Winner 5 - Arran Walker (his solution).

According to the challenge author, David Le Corfec and William Shallum were close to one another.


This challenge’s sponsors are: Anand D N, Apcera, CoreOS, Crowd Interactive, Cube Root Software, DigitalOcean, Docker, GitHub, GopherCasts, Helpshift, InfluxDB, John Sonmez, JoshSoftware Pvt. Ltd., Manning Publications Co., NodePrime, O’Reilly, Packt Publishing, Qwinix Technologies, RainingClouds, SoStronk and Sourcegraph.


  • The Gopher character is based on the Go mascot designed by Renée French and copyrighted under the Creative Commons Attribution 3.0 license.
  • GitHub for the yearly sponsorship of a GitHub Bronze Organisation plan for the Go Challenge.
  • The Go Challenge is being organized by JoshSoftware Pvt. Ltd. with help from the Go community.
Written on March 31, 2015