|
🔗 Stories, Tutorials & Articles |
|
|
|
Providing context to cancellations in Go 1.20 with the new context WithCause API |
|
|
A blog post about a new feature in the Go programming language, specifically in the context package. Prior to version 1.20, Go did not have good options for understanding why a context was cancelled. It was limited to only two options context.DeadlineExceeded or context.Canceled. But with Go 1.20, a new WithCause API has been added to the context package, which allows developers to provide custom error types when cancelling the context. This will allow developers to provide more context as to why the context was cancelled, such as whether the operation is safe to retry or not. The new WithCancelCause, WithDeadlineCause, and WithTimeoutCause APIs are now available in Go 1.20. |
|
|
|
|
|
|
|
Faster Go code by being mindful of memory ✅ |
|
|
The author is discussing a particular puzzle and how it's a good example of how efficient memory management can lead to better performance. The puzzle is about finding the first consecutive block of 14 bytes in a stream of bytes, where all 14 bytes are different. The author and a friend are solving this puzzle using the Go programming language and are trying to find a balance between simplicity and performance in their solutions. |
|
|
|
|
|
|
Some Useful Patterns for Go's os/exec |
|
|
The tutorial explains how to use the os/exec package in Go to spawn and interact with background processes, with specific focus on the Dolt project, which is an SQL database with Git-like version control. The author provides examples and explanations of how to use the os/exec package, including basic usage, running a process and waiting for completion, sharing standard output, and capturing output. It points out that Go's os/exec package has robust facilities for error handling and concurrency and provides a good replacement for scripts that rely on shell commands. |
|
|
|
|
|
|
Apache AVRO and Go: encoding and decoding |
|
|
A tutorial that describes how to use the Apache Avro serialization framework in the Go programming language to encode and decode data. Avro is used to compress data payloads in the Apache Kafka ecosystem and is typically used when you need to serialize your data into bytes, and then decode those bytes into data structures. The article explains that Avro requires a schema to convert the data into bytes and the same schema to convert bytes back into an existing data structure. This allows for more efficient compression of data because metadata (such as the names and types of variables) can be stored in the schema rather than with the data itself. The author provides examples of how to use the Avro serialization framework in Go and how it compares to the JSON format. |
|
|
|
|
|
|
passit: a password generation toolkit for Go |
|
|
This blog post describes a password generation toolkit for Go programming language called 'passit'. It includes two CLI commands, "passphrase" and "twoproblems", that can be used to generate random passphrases or passwords based on regular expression templates respectively. The passphrase command takes command-line arguments such as wordlist, number of words, and separator to use. The twoproblems command also takes regular expression template as an argument. The package also provides a number of generators that can be used programmatically to generate passwords. These generators return output from a fixed set such as digits, lowercase or uppercase alphabets, etc. |
|
|
|
|