Best of GolangAugust 2024

  1. 1
    Article
    Avatar of bytebytegoByteByteGo·2y

    EP125: How does Garbage Collection work?

    Garbage collection is a crucial automatic memory management feature used in many programming languages. Java offers multiple garbage collectors tailored to different scenarios, Python employs reference counting alongside a cyclic collector to handle circular references, and GoLang utilizes a concurrent mark-and-sweep garbage collector to minimize application pauses. Additional topics include tools for designing fault-tolerant systems and key system design trade-offs.

  2. 2
    Article
    Avatar of communityCommunity Picks·2y

    Build Redis from scratch

    This series guides you through building an in-memory database similar to Redis using Go. It focuses on low-level details involving databases, data structures, and algorithms. The project highlights include understanding RESP for command parsing, using goroutines for multiple connections, and implementing data persistence with the Append Only File (AOF) method. Suitable for developers familiar with Go and Redis commands.

  3. 3
    Article
    Avatar of lobstersLobsters·2y

    Go is my hammer, and everything is a nail

    Markus, a solo developer, advocates for using a single programming language, specifically Go, for all development tasks. He believes that this approach simplifies his tech stack, enhances productivity, and allows him to delve deeper into the language's features. Markus emphasizes that while most popular programming languages can accomplish various tasks, choosing one aligns better with his lifestyle and work preferences.

  4. 4
    Article
    Avatar of gcgitconnected·2y

    Why Use GoFr for Golang Backend?

    GoFr is a Golang framework designed for accelerated microservice development. It offers built-in observability tools such as health-check and heartbeat URLs, metrics, and structured logging. GoFr supports multiple data sources including MySQL, PostgreSQL, and MQTT, and simplifies REST API design, logging, metrics, tracing, and CORS configuration. Its compatibility with Kubernetes and minimal code for route registration enable developers to focus on business logic while ensuring the application is production-ready.

  5. 5
    Article
    Avatar of communityCommunity Picks·2y

    Model Validation in Golang

    Model validation is essential for ensuring the integrity of software. Golang's validator v10 library is highly recommended due to its extensive features and large community support. The post details how to use field tags, custom validation functions, and offers best practices for fail-fast methodology and avoiding global state. Practical examples demonstrate the use of validation tags and custom struct validation, making the process straightforward and efficient.

  6. 6
    Article
    Avatar of communityCommunity Picks·2y

    How To Write Maintainable Go Code?

    Maintainable Go code emphasizes simplicity, readability, and clarity to help new team members easily understand and continue the work. Key strategies include keeping the `main` function minimal, using meaningful names, writing clear comments, avoiding repetitive code, minimizing deep nesting, using early returns to reduce code complexity, and preferring switch cases over if-else statements. Continuous refactoring is crucial to keep the codebase modern and secure.

  7. 7
    Article
    Avatar of awegoAwesome Go·2y

    Golang Defer: From Basic To Traps

    The defer statement in Go delays the execution of a function until the surrounding function finishes, useful for cleanup actions like closing resources. There are three types of defer in Go: heap-allocated, stack-allocated, and open-coded, each with different performance characteristics. Multiple defers are executed in a last-in-first-out order, and recover can regain control after a panic within a deferred function. Deferred function arguments are evaluated immediately, which can lead to complexities if not handled properly. Proper error handling with defer includes capturing defer return values.

  8. 8
    Article
    Avatar of atomicobjectAtomic Spin·2y

    Is Go Programming Language Worth Using on Your Next Project?

    Go, also known as Golang, offers a C-like syntax but with its unique take, such as reading declarations left to right and a garbage collector to ease memory management. Though it lacks features like exceptions (using 'panics' instead) and traditional classes, it utilizes structs and interfaces. Go supports concurrency through lightweight goroutines and channels for communication, making it highly efficient. Although not flashy, its simple syntax and efficient performance make it dependable and relatively easy to learn, especially for those familiar with other languages.

  9. 9
    Video
    Avatar of dreamsofcodeDreams of Code·2y

    Function iterators aren't as bad as I thought...

    Go 1.23 introduces several new features, with function iterators being the most notable. This has sparked discussions due to its initial potential to obscure concurrent execution, which has been addressed in this release. The update also enhances readability through the iter package and adds iterator support to standard library packages like slices and maps. Future iterations may include more utility functions, making iterators easier to work with.

  10. 10
    Article
    Avatar of communityCommunity Picks·2y

    The 4-chan Go programmer

    Explores an unconventional approach to using channels in Go by creating a highly nested and complex channel structure for performing tasks. Highlights the intricacies of using channels and goroutines, referencing the drawbacks and impracticalities of overly clever concurrency patterns. Provides a practical example, albeit not recommended for real-world use due to its complexity and difficulty in debugging, and touches upon Dolt, a version-controlled SQL database.

  11. 11
    Article
    Avatar of awegoAwesome Go·2y

    Building BLE Applications with BleuIO and Go

    This tutorial provides step-by-step guidance on building Bluetooth Low Energy (BLE) applications using the BleuIO USB dongle and the Go programming language. It covers setting up the development environment, installing required packages, and writing a Go program to interact with the BLE dongle. Key features of BleuIO, including its easy-to-use AT Commands and cross-platform support, are also highlighted.

  12. 12
    Article
    Avatar of hnHacker News·2y

    d3witt/viking: Simple way to manage your remote machines and SSH keys

    Viking is a tool that simplifies the management of remote machines and SSH keys, offering commands to execute shell commands, manage SSH keys, configure settings, and handle multiple remote machines. It supports installations on Unix and Windows systems and allows usage of SSH Agent if keys are not specified. Viking stores data locally but the directory can be customized.

  13. 13
    Article
    Avatar of phpdevPHP Dev·2y

    Are you thinking of moving from PHP to Go? Read this first!

    Considering transitioning from PHP to Go? Explore the potential benefits and differences between these two programming languages, and find out if Go is a suitable choice for your next project.

  14. 14
    Video
    Avatar of youtubeYouTube·2y

    C# (.NET) vs. Go (Golang): Performance Benchmark in Kubernetes

    A performance benchmark comparison between C# (.NET 8) and Golang in a Kubernetes environment, testing CPU usage, memory usage, request handling, and end-user latency. The tests include a minimal API test and a typical use case with file upload to S3 and metadata storage in a Postgres database. Golang generally performs better, with lower CPU and memory usage, while C# shows higher latency. The post includes detailed metrics and setups for monitoring using Prometheus, Grafana, and cAdvisor.

  15. 15
    Article
    Avatar of communityCommunity Picks·2y

    Create a Golang DNS Resolver: Step-by-Step Guide

    This post walks readers through the process of building a DNS Resolver in Golang, from understanding DNS messages and choosing the appropriate language to implementing caching with SQLite. It starts with the basics of DNS and the reasons for choosing Golang, followed by detailed code examples of struct definitions, message conversion, network communication, and response parsing. An additional caching layer is demonstrated using SQLite for efficiency. The author concludes by reflecting on the learning experience and inviting contributions to the project.

  16. 16
    Article
    Avatar of freecodecampfreeCodeCamp·2y

    How to Implement Server-Sent Events in Go

    Server-Sent Events (SSE) offer a straightforward way to enable real-time, one-way communication from servers to clients. This guide explains how to implement SSE in Go, covering its benefits, use cases, and providing code examples for both server and client sides. Key advantages include simplicity, native browser support, and automatic reconnection. It also highlights best practices like using JSON for event formatting and handling reconnections efficiently.

  17. 17
    Article
    Avatar of communityCommunity Picks·2y

    Go Parse, Don't Validate

    A developer shares their experience solving a bug where lead data submissions occasionally missed phone and email information due to null pointers. Instead of simple validation checks, the article advocates for using parsing to ensure type safety and more reliable error handling. By creating new types that inherently handle potential errors, the code can prevent issues at their origin and improve overall bug-freeness and clarity.

  18. 18
    Article
    Avatar of communityCommunity Picks·2y

    gRPC From Scratch: Part 1 - Client

    An in-depth exploration of the gRPC protocol, explaining its structure and underlying mechanisms. The post covers the basics of creating a gRPC client in Go, detailing how requests and responses are encoded and decoded at a byte level. It also briefly touches on the topic of gRPC streaming and provides a simple example to get started.

  19. 19
    Article
    Avatar of awegoAwesome Go·2y

    Escape JavaScript hell and write everything in Go

    The post describes an annual remake of a personal website using a new web stack focusing on HTMX and Go to avoid JavaScript/TypeScript complications. The author discusses the advantages of this approach for smaller, non-interactive HTML displays and explains the benefits of using tools like PocketBase, templ, TailwindCSS, and AlpineJS. The post emphasizes server-side rendering and the ease of making UIs without client-side state management.

  20. 20
    Article
    Avatar of bitfieldconsultingBitfield Consulting·2y

    Functional programming in Go — Bitfield Consulting

    Functional programming in Go enhances code organization by using functions as primary control structures. Key operations include mapping a function over a slice, filtering elements based on a function, and reducing a slice to a single value with a function. These operations can simplify and elegantly solve many problems. The post demonstrates how to implement `Map`, `Filter`, and `Reduce` functions in Go, highlighting their usage and versatility.

  21. 21
    Article
    Avatar of newstackThe New Stack·2y

    Golang Pub/Sub: Why It’s Better When Combined With GoFr

    Modern systems require reliable, scalable, and real-time communication, often achieved using pub/sub (publish-subscribe) architectures. Golang, with its simplicity and efficiency, combined with the GoFr framework, offers an optimal solution for building these systems. GoFr simplifies pub/sub setups by abstracting boilerplate code, supporting multiple message brokers, providing built-in monitoring and security, and optimizing for IoT with MQTT. This makes it ideal for high-throughput, low-latency communication necessary for IoT and other real-time applications.

  22. 22
    Article
    Avatar of hnHacker News·2y

    will-moss/isaiah: Self-hostable clone of lazydocker for the web. Manage your Docker fleet with ease

    Isaiah is a self-hostable web-based service that allows you to manage Docker resources on remote servers. It offers extensive features like bulk updates, live logs inspection, and shell access from the browser for stacks, containers, images, volumes, and networks. It supports multi-node and multi-host deployments, built-in authentication, responsive design, custom theming, and extensive configuration. Written in Go and Vanilla JS, Isaiah can be deployed via Docker or as a standalone application with minimal resource usage.

  23. 23
    Article
    Avatar of awegoAwesome Go·2y

    Build Go Serverless REST APIs and Deploy to AWS using the SAM framework (Amazon Linux 2 Runtime)

    Learn how to build and deploy Go serverless REST APIs using AWS SAM framework. The post highlights the deprecation of Go1.x for AWS Lambda, emphasizing the need for up-to-date tutorials. It emphasizes key software development principles such as Infrastructure as Code, good naming conventions, robust testing strategies, availability & scalability, deployment pipelines, observability, and security. A comprehensive example is provided illustrating these principles in a serverless architecture.

  24. 24
    Article
    Avatar of awegoAwesome Go·2y

    What's the best Static Analysis tool for Golang?

    When writing Golang code, ensuring that all return errors are checked can be challenging. Traditional tools like golint and go vet fall short in catching all errors. However, tools like errcheck and StaticCheck offer specific checks but require manual management. The Go Analysis API enables combining multiple tools into a single driver, and golangci-lint effectively runs various static analyzers together, providing a comprehensive static analysis solution for Golang. It integrates well with IDEs and CI pipelines, improving code reliability by catching non-obvious bugs.

  25. 25
    Article
    Avatar of freecodecampfreeCodeCamp·2y

    How to Terminate Go Programs Elegantly – A Guide to Graceful Shutdowns

    Graceful shutdowns prevent data loss and system instability by allowing applications to complete ongoing requests and save state information. In Go applications, this involves handling Unix signals like SIGTERM using signal channels or context. Proper implementation ensures in-flight requests are completed, and resources like Redis connections are closed before exiting. This is crucial for applications in orchestrated environments like Kubernetes, where the termination process includes signal sending and waiting periods.