|
2 | 2 |
|
3 | 3 | 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.
|
4 | 4 |
|
| 5 | +## Gems and Off-the-beaten Path |
5 | 6 |
|
6 |
| - * [add_two_numbers](./add_two_numbers) |
7 |
| - * [main.go](./add_two_numbers/main.go) |
8 |
| - * [binary_uint8_reversal](./binary_uint8_reversal) |
9 |
| - * [main.go](./binary_uint8_reversal/main.go) |
10 |
| - * [caesar_cipher](./caesar_cipher) |
11 |
| - * [main.go](./caesar_cipher/main.go) |
12 | 7 | * [composite_literals](./composite_literals)
|
13 | 8 |
|
14 | 9 | It is important to understand what **composite literals** mean in Go through some interesting use-cases
|
| 10 | + |
| 11 | + * [for_with_label](./for_with_label) |
| 12 | + |
| 13 | + For loops can have break and continue statements with **labels**. This is a useful but less well-known feature. |
| 14 | + |
| 15 | + * [runes_bytes_loops](./runes_bytes_loops) |
| 16 | + |
| 17 | + A must-understand for serious programmers. Simple program demonstrating tricky [concepts](https://blog.golang.org/strings). 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? |
| 18 | + |
| 19 | + * [slice_gotchas](./slice_gotchas) |
| 20 | + |
| 21 | + Do you know that this does not cause an out of bounds error? |
| 22 | + |
| 23 | + ```go |
| 24 | + c := make([]int, 3) |
| 25 | + fmt.Println(c[len(c):len(c)]) |
| 26 | + ``` |
| 27 | + |
| 28 | + * [slice_tricks](./slice_tricks) |
15 | 29 |
|
16 |
| - * [main.go](./composite_literals/main.go) |
| 30 | + Implementation of simple functions that demonstrate interesting slice operations such as [**extending, expanding and inserting**](https://github.com/golang/go/wiki/SliceTricks) elements. |
| 31 | + |
| 32 | + * [variadic_functions](./variadic_functions) |
| 33 | + |
| 34 | + Variadic functions in Go are certainly off-the-beaten path. One hidden gem is **interface{} variadic functions** |
| 35 | + |
| 36 | +## Classic Problems |
| 37 | + |
| 38 | + * [add_two_numbers](./add_two_numbers) |
| 39 | + * [binary_uint8_reversal](./binary_uint8_reversal) |
| 40 | + * [caesar_cipher](./caesar_cipher) |
17 | 41 | * [eratosthenes](./eratosthenes)
|
18 | 42 |
|
19 | 43 | A Classic problem but I wanted to dig deeper into the number theory behind it. I suggest reading
|
20 | 44 | [Why in Sieve of Erastothenes of 𝑁 number you need to check and cross out numbers up to 𝑁‾‾√? How it's proved?](https://math.stackexchange.com/questions/58799/why-in-sieve-of-erastothenes-of-n-number-you-need-to-check-and-cross-out-numbe)
|
21 | 45 |
|
22 |
| - * [main.go](./eratosthenes/main.go) |
23 |
| - * [for_with_label](./for_with_label) |
24 |
| - |
25 |
| - For loops can have break and continue statements with **labels**. This is a useful but less well-known feature. |
26 |
| - |
27 |
| - * [main.go](./for_with_label/main.go) |
28 | 46 | * [go_routines_gotchas](./go_routines_gotchas)
|
29 |
| - * [main.go](./go_routines_gotchas/main.go) |
30 | 47 | * [is_rotation](./is_rotation)
|
31 |
| - * [main.go](./is_rotation/main.go) |
32 | 48 | * [longest_substring](./longest_substring)
|
33 |
| - * [main.go](./longest_substring/main.go) |
34 | 49 | * [median_sorted_arrays](./median_sorted_arrays)
|
35 |
| - * [main.go](./median_sorted_arrays/main.go) |
36 | 50 | * [one_away](./one_away)
|
37 |
| - * [main.go](./one_away/main.go) |
38 | 51 | * [palindromes](./palindromes)
|
39 |
| - * [main.go](./palindromes/main.go) |
40 | 52 | * [permutations](./permutations)
|
41 |
| - * [main.go](./permutations/main.go) |
42 |
| - * [runes_bytes_loops](./runes_bytes_loops) |
43 |
| - |
44 |
| - A must-understand for serious programmers. Simple program demonstrating (sometimes tricky) concepts found in https://blog.golang.org/strings. 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? |
45 |
| - |
46 |
| - |
47 |
| - * [main.go](./runes_bytes_loops/main.go) |
48 |
| - * [slice_tricks](./slice_tricks) |
49 |
| - |
50 |
| - Implementation of https://github.com/golang/go/wiki/SliceTricks. Simple functions that demonstrate interesting slice operations such as **extending, expanding and inserting** elements. |
51 |
| - |
52 |
| - * [main.go](./slice_tricks/main.go) |
53 | 53 | * [two_sum](./two_sum)
|
54 |
| - * [main.go](./two_sum/main.go) |
55 | 54 | * [unique_chars](./unique_chars)
|
56 |
| - * [main.go](./unique_chars/main.go) |
57 | 55 | * [urlify](./urlify)
|
58 |
| - * [main.go](./urlify/main.go) |
59 |
| - * [variadic_functions](./variadic_functions) |
60 |
| - |
61 |
| - Variadic functions in Go are certainly off-the-beaten path. One hidden gem is **interface{} variadic functions** |
| 56 | + |
62 | 57 |
|
63 |
| - * [main.go](./variadic_functions/main.go) |
0 commit comments