Profile cover photo
Profile photo
Stefan Nilsson
About
Posts

Post has attachment
Here are two short code snippets that might come in handy.

Post has attachment
Go has only one looping construct, the for loop, but its quite versatile.

Post has attachment
To convert between string and integer in Go, you can use Atoi, ParseInt, Itoa, and FormatInt in package strconv, as well as fmt.Sprintf.

Post has attachment
A quick tutorial and cheat sheet on how to best use the fmt package.

Post has attachment
Go has two library functions for comparing slices: bytes.Equal and reflect.DeepEqual. In most other cases, you will want to write your own code.

Post has attachment
This cheat sheet contains all time/date formatting options, several common time formats and a few corner cases.

Post has attachment
Here is a handy template I often use when writing small Go scripts. It's a simplified version of the Unix grep command.

Post has attachment
An overview of the most commonly used Go string functions.

Post has attachment
Go regular expression basics and cheat sheet.

Post has attachment
Here is an elementary article about the fastest known algorithm for sorting word-sized integers. It runs in O(n log log n) worst-case time.

Note that a normal radix sort won't cut it. It runs in Θ(wn) time, where the word length w is at least log n. (Since each memory address is a word consisting of w bits, the address space won’t accommodate n numbers if w < log n. )
Wait while more posts are being loaded