A Better Way of Handling Stdin

 featured, tricks

I usually pipe content to programs that depend on some kind of input from stdin. Annoyingly enough, when running the program manually and forgetting to pipe content, it hangs. To

Create Test Files in Your Temp Directory


When running tests that require static files/directories to be generated, I used to just create them in the same working directory wherever the go test command was executed. It

Go's Time Package in a Few Minutes


Hard to believe that March was the last time anything has been published. Since then, I've graduated from school and have been very fortunate enough to land a gig where



golang.recipes which is a resource of Go files that convey examples of Go. My last semester of school was so packed that I only programmed in Go once. Getting

Using the text/template package in Go

This week I'm working with the text/template package. As the page describes, "Package template implements data-driven templates for generating textual output." In a nutshell, a template can be a

It's Been a While!

I've taken some time off to focus on my final year of school. Unfortunately that meant being away from Go for quite a while, and man did I miss a

Happy Birthday, Dennis Ritchie!

I would like to take the pleasure of saying happy birthday to Dennis Ritchie, creator of the C Programming Language, the R in the famous and revered K&R

A Binary Tree in Go

Most of the implementations that I've seen online are restricted to only one type. As a refresher I've followed suit and implemented a basic binary tree which works with integers.

Late Post

Just wanted to mention that the weekly post which was intended to be released within the past couple of days is still being written. Consistency and dependability mean a lot

Notes on Go's Slice Data Type

This post will mostly be helpful if you're new to slices in Go. When it comes to understanding slices, Andrew Gerrand's post Go Slices: usage and internals is always brought

Go's unsafe.Pointer Pointer Type

I was trying find the size of a type in bytes and found that the sizeof function of the unsafe package does the trick. This also led me to stumble

Garbage Collector Change in Go 1.3

I was in the middle of writing a post on using Go's Pointer data type and realized that Go 1.3 affects how it can be used. Here's demonstration of

Alternate Ways of Importing Packages

There a couple more ways of importing packages in addition to the widely used method of using the import keyword and package name as a string literal. Let's take a

Insertion Sort with an Empty Interface and Tests

If you're not familiar with insertion sort, I recommend this awesome four minute video which depicts insertion sort in Romanian folk dance. This implementation of a polymorphic insertion sort strengthened

A Quine in Go

tl;dr Quines are cool. Create one and share yours! Before I slept last night, I read a post on /r/golang that invited people to post their own version

Bubble Sort

EDIT (06/05/2014): Code in this post is now available here as a single, executable file. Added a section to this post containing code to test the bubble sort

First Post!


Hi! Took a while to get things going, but it's finally up. For now, learngowith.me will be a series of random content that I find useful in my adventures