/explore

Click through on any links that interest you or select the planets on the right to continue exploring the Outer Web.
You are here

codeexplainer.wordpress.com
| | blog.nuculabs.de

Hi In this article I want to highlight a simple pattern for sorting a slice in Go on multiple keys. Given the following structure, let's say we want to sort it in ascending order after Version, Generation and Time. 1 2 3 4 5 type TheStruct struct { Generation int Time int Version int } The way we sort slices in Go is by using the sort interface or one of the sort.Slice functions. To sort the slice after the above criteria we'll call slice.Sort with the following function.
4.9 parsecs

Travel
| |
| | zserge.com

Making music with low-level C code, from a simple saw wave to playing melodies
6.5 parsecs

Travel
| |
| | schadokar.dev

Convert Hexadecimal to Decimal and Decimal to Hexadecimal
7.4 parsecs

Travel
| |
| | hjr265.me

Concurrency is one of the central features of Go. And, to build concurrent programs in Go, you need goroutines. A goroutine is like a thread, but lighter. Much lighter. And, like any other built-in feature of Go, using it is dead simple: 1 2 3 4 5 6 7 package main func main() { go func() { println("Hello World") // Print "Hello World" from a different goroutine. }() } Wait. That didn't print anything.
25.6 parsecs

Travel
|