The goal is to compile hidden gems and off-the-beaten path Go features and patterns. This is not meant to be a library or reference implementation.
-
A dramatic example of Go Closures. A two-level closure pattern.
-
It is important to understand what composite literals mean in Go through some interesting use-cases
-
For loops can have break and continue statements with labels. This is a useful but less well-known feature.
-
A must-understand for serious programmers. Simple program demonstrating tricky concepts. Do you know that 'a' is a int32, str[0] is a uint8, the value of position 0 in a range loop is a rune?
Do you know that this does not cause an out of bounds error?
c := make([]int, 3)
fmt.Println(c[len(c):len(c)])
-
Implementation of simple functions that demonstrate interesting slice operations such as extending, expanding and inserting elements.
-
Let's look under the hood and see how strings are represented in Go and print a string by walking the memory addresses, C-style.
-
Variadic functions in Go are certainly off-the-beaten path. One hidden gem is interface{} variadic functions
-
A Classic problem but I wanted to dig deeper into the number theory behind it. I suggest reading Why in Sieve of Erastothenes of 𝑁 number you need to check and cross out numbers up to 𝑁‾‾√? How it's proved?