random thoughts a journey to nowhere

Structured Logging in Golang

Table Of Content Table Of Content log/slog A very basic example Configuration Wrapping Writing to file Tips So you want to use the new shiny structured logging library in golang log/slog slog (a structured logging library in Go) has been included in the Go standard library starting from version 1.21. While Go already had a lo... Read more

Trace Log in Golang

Disclaimer: This article is not about runtime/trace package or trace profiling functionalities. Tracing is used to observe code execution paths. If you log something in a function and you see that output in the log file, then you know that the function has been executed. There is a log level defined in different logger implementations called TR... Read more

Signal handling and graceful shutdown in Go

Table Of Contents Graceful Shutdown What are signals in OS context? An Example Program An automated way to send signals What are the available signals? SIGINT SIGTERM SIGKILL Why did we initialize the sigCh as buffered channel? Signal Broadcast ... Read more

Working with SSH in Linux and macOS

Table of contents TL;DR Generate keys Start ssh-agent Add keys to ssh-agent Add keys to a remote server Remove keys from a remote server Remove host from known_hosts file Debug What is SSH? Using SSH Our demo machine Logging into the machine Generating keys Upload our keys Us... Read more

Symmetric Encryption With ChaCha20Poly1305

Table Of Contents Symmetric Encryption ChaCha20 Encryption Cipher Text Size Decryption Where to put the nonce? The Full Code Variable Sized Password This post is not completed yet Recently, I’ve started learning... Read more