Best of GolangSeptember 2024

  1. 1
    Video
    Avatar of youtubeYouTube·2y

    Complete Backend Engineering Course in Go

    This post introduces a comprehensive backend engineering course in Go, designed to take learners from basic to advanced topics. The course aims to teach how to build RESTful APIs and other backend systems, applying the knowledge to microservices as well. The curriculum includes 21 modules, covering areas such as TCP and HTTP server development, routing, clean layered architecture, database management using the repository pattern, CRUD operations, user authentication and authorization, caching, performance optimization, and CI/CD deployment workflows. The course materials and code are available on GitHub, and the instructor emphasizes understanding concepts over mere code replication.

  2. 2
    Article
    Avatar of threedotslabsThree Dots Labs·2y

    Database Transactions in Go with Layered Architecture

    This post explores handling database transactions in Go while adhering to layered architecture principles. It emphasizes the importance of keeping critical logic separate from SQL queries using patterns such as the Repository pattern, the UpdateFn pattern, and the Transaction Provider pattern. Various approaches to transaction management are discussed, highlighting their advantages and drawbacks to help maintain code clarity and integrity.

  3. 3
    Article
    Avatar of golangGo·2y

    Building LLM-powered applications in Go

    As Large Language Models (LLMs) and embedding models improve, more developers are integrating LLMs into their applications. Go excels in building LLM-powered applications due to its support for REST/RPC protocols, concurrency, and performance. This post demonstrates creating a Retrieval Augmented Generation (RAG) server in Go, which uses HTTP endpoints to add documents to a knowledge base and answer user questions. It explores implementing this with tools like Google Gemini API, Weaviate, LangChainGo, and Genkit for Go, highlighting Go's strengths in cloud-native application development.

  4. 4
    Article
    Avatar of hnHacker News·2y

    The Modern CLI Renaissance

    In recent years, there's been a resurgence in the development of command line interface (CLI) tools, driven by advancements in terminal capabilities and user demands for improved usability. This trend is characterized by rethinking and reinventing long-standing tools to offer better out-of-the-box experiences, more helpful error messages, and streamlined common use cases. The article discusses the historical development of CLI tools, lessons learned over decades, and the impact of modern programming languages like Rust and Go in this renaissance.

  5. 5
    Article
    Avatar of gitguardianGitGuardian·2y

    How to Handle Secrets in Go

    Learn how to handle secrets in Golang, exploring various methods like reading from ENV files, using secret managers, and leveraging platform-managed identities. The most secure approach is to synchronize secrets from the secret manager to the runtime environment, enabling seamless integration without altering the app's code. Avoid token-based methods and reading directly from ENV files for better security in cloud-native applications.

  6. 6
    Article
    Avatar of last9Last9·2y

    Golang Logging: A Comprehensive Guide for Developers

    Logging in Go is essential for debugging and maintaining application performance. While the standard log package offers basic functionality, third-party libraries like Zerolog and Zap provide advanced features like structured logging and configurable log levels. Implementing best practices, such as avoiding sensitive data in logs and using context-rich messages, can significantly enhance log analysis and troubleshooting. Integrating with observability platforms like ELK can further improve monitoring capabilities in production environments.

  7. 7
    Video
    Avatar of codeheimcodeHeim·2y

    #55 Golang - Get Started with gRPC in Golang – Server & Client

    Explore how gRPC, a high-performance RPC framework, allows seamless communication between services in Golang. Learn about its benefits over REST, how to set up gRPC and protocol buffers in a Go project, and see an example project structure implementing CRUD operations with gRPC.

  8. 8
    Article
    Avatar of awegoAwesome Go·2y

    The differences between "Type Alias" and "New Types" in Go

    Learn the differences between type aliases and new type declarations in Go. A type alias serves as a nickname for an existing type, ensuring full compatibility without the need for type conversions. In contrast, new type declarations create entirely new types that require explicit conversions and can add domain-specific methods for enhanced type safety. Make informed decisions between the two based on your code's needs for refactoring or creating domain-specific logic.

  9. 9
    Article
    Avatar of hnHacker News·2y

    peer-calls/peer-calls: Group peer to peer video calls for everyone written in Go and TypeScript

    Peer Calls is a group peer-to-peer video calling application written in Go and TypeScript. The new version includes a rewritten server in Golang, an optional Selective Forwarding Unit (SFU) for reduced bandwidth usage, and numerous features and fixes like improved file sending, device management, and toolbar layout. It supports dynamic stream handling, multiple nodes, and end-to-end encryption. Deployment can be done via Docker or using kubectl with a YAML config file. Redis can be utilized for load balancing, and a TURN server can be configured for better connectivity behind firewalls.

  10. 10
    Article
    Avatar of vikingsoftwareViking Software·2y

    Battle of the Backends

    This post discusses the pros and cons of various programming languages for web backend development, including Rust, Go, C#, and Python. The author highlights Rust's advantages in dependency handling but notes its ecosystem's immaturity. Go is praised for its environment, but its stagnation in updates is a concern. C# is appreciated for its ease of development but criticized for occasional performance issues. Python is deemed suitable only if there's existing developer expertise. A strong stance is taken against using Javascript for backends.

  11. 11
    Article
    Avatar of systemweaknessSystem Weakness·2y

    Naabu port scanner

    Naabu is a fast port scanner written in Go, designed to be reliable and simple to use, especially useful in conjunction with other tools for attack surface discovery in bug bounties and pentests. It can be installed from its GitHub page and comes with various switches similar to Nmap for different functionalities like live host scanning, defining ports, threading, and rate limiting. It's particularly efficient for scanning multiple targets compared to Nmap.

  12. 12
    Article
    Avatar of freecodecampfreeCodeCamp·2y

    How to Work with SQL Databases in Go – Different Approaches and Examples

    The post explores various Go packages for working with SQL databases, including the built-in database/sql, sqlx, GORM, and sqlc. It covers their strengths and weaknesses, providing hands-on examples for each. Additionally, it touches on database migrations in Go and offers a brief comparison of migration tools like golang-migrate and goose.

  13. 13
    Article
    Avatar of communityCommunity Picks·2y

    Interning in Go

    Go 1.23 introduces a new package, unique, for interning objects to reduce memory usage by re-using objects of equal value rather than keeping duplicates in memory. Examples include handling large strings and slicing them to create smaller substrings for efficient memory management. Interning helps in various environments like stateful web servers and batch jobs where memory resources are limited.

  14. 14
    Video
    Avatar of youtubeYouTube·2y

    Node.js vs Golang: Performance Benchmark in Kubernetes #210

    The performance benchmark compares Node.js with Go by deploying web applications to a Kubernetes cluster on AWS using EC2 instances. The tests measure CPU and memory usage, latency, CPU throttling, network pressure, and application availability. Go significantly outperforms Node.js, handling around 70,000 requests compared to Node.js's 9,000 requests before performance degrades. Additional tests include inserting data into a Postgres database, revealing similar latency but higher resource usage for Node.js.

  15. 15
    Article
    Avatar of communityCommunity Picks·2y

    Dockerizing a Golang API with MySQL and adding Docker Compose Support

    Developing and testing APIs locally with databases can be streamlined using Docker. This guide shows how to Dockerize a Golang API with MySQL, leveraging best practices like using lighter base images, multi-stage builds, creating binaries, and breaking down layers. It also covers how to set up Docker Compose to manage the API and MySQL containers, ensuring seamless integration and easy management.

  16. 16
    Article
    Avatar of datadogDatadog·2y

    How to spot and fix memory leaks in Go

    Memory leaks in Go can occur despite its garbage collector. They can result from unbounded resource creation, long-lived references, improperly terminated goroutines, deferred function calls in loops, and improper use of time.Ticker. Identifying such leaks involves monitoring memory usage patterns and using tools like pprof for code profiling. Continuous profiling tools like Datadog's Continuous Profiler can further help by providing continuous metrics and visualizations to detect and resolve memory issues.

  17. 17
    Article
    Avatar of hnHacker News·2y

    Postgres webhooks with pgstream

    Set up and trigger webhooks in response to PostgreSQL data and schema changes using pgstream, a Change-Data-Capture (CDC) tool. The guide covers initial setup with Docker, webhook configuration, handling basic operations like inserts, updates, and deletes, as well as advanced features like sending old and new values during updates and managing schema changes. Detailed examples demonstrate how to automate workflows and trigger real-time notifications in your applications.

  18. 18
    Article
    Avatar of hnHacker News·2y

    CPU Throttling for containerized Go applications explained

    CPU throttling can significantly affect containerized Go applications, leading to increased latencies and service interruptions. The issue arises because Go's runtime doesn't recognize the CPU limits set by Kubernetes, causing the application to overconsume resources and get throttled. Solutions include setting the GOMAXPROCS variable appropriately and using tools like automaxprocs to align Go's runtime with Kubernetes' CPU quotas. Understanding Kubernetes' Completely Fair Scheduler (CFS) and correctly configuring resource limits and requests are crucial to mitigating throttling issues.

  19. 19
    Article
    Avatar of glwGolang Weekly·2y

    Golang Weekly Issue 524: September 24, 2024

    Go 1.24 will introduce generic alias types to improve refactoring without breaking compatibility, expected in February 2025. The singleflight package helps manage concurrency by ensuring a function runs only once with its result reused. Rueidis is a high-performance Redis client with caching and support for many Redis extensions. Updates include GoCV 0.38.0, MongoDB Go Driver 1.17, Buf 1.42, automaxprocs 1.6, River 0.12, and Goyave 5.3.

  20. 20
    Article
    Avatar of evolvedevevolvedev·2y

    Building a Google Drive Downloader in Golang (Part 1)

    Learn how to create a powerful downloader in Golang, enabling efficient concurrent downloads from Google Drive and other cloud providers. Manage multiple downloads, stream large files, and track progress in real-time.

  21. 21
    Article
    Avatar of awegoAwesome Go·2y

    Go long by generating PDFs in Golang with Maroto

    Golang, known for its performance and efficiency, is an excellent choice for generating PDFs at scale, using the Maroto library inspired by Bootstrap’s layout system. Maroto simplifies layout management with rows and columns, supports various elements like text, images, and QR codes, and handles automatic page breaks. The guide provides step-by-step instructions to create dynamic PDFs, including project initialization, dependency installation, and building elements like headers, bodies, and footers.

  22. 22
    Article
    Avatar of ebpfeBPF·2y

    Transparent Proxy Implementation using eBPF and Go

    A transparent proxy intercepts and redirects client requests without the need for client-side configuration, making it valuable for network management and security. Implementing this with eBPF and Golang, the post outlines three main eBPF programs for address replacement, source address recording, and forwarding based on original destination information. The performance evaluation indicates minimal impact on latency and CPU load, showcasing eBPF's efficiency for high-performance packet processing.

  23. 23
    Article
    Avatar of awegoAwesome Go·2y

    The Go Programming Language

    The Go Playground is a web service hosted on go.dev's servers, allowing users to run Go programs within a sandbox. It supports most of the standard library except for certain cases and restricts communication to standard output and error. The service is useful for running Go code snippets and tests, but it has limitations on execution time, CPU, and memory usage. Users can integrate the service into their websites with prior permission and a unique user agent.

  24. 24
    Article
    Avatar of awegoAwesome Go·2y

    How to Publish a Golang Package

    Learn how to publish a Golang package to share your tools with the community. This guide walks through setting up your module with the correct naming conventions, pushing your code to GitHub, and uploading it to pkg.go.dev. It also highlights best practices such as licensing, documentation, and tagging for stable releases.

  25. 25
    Video
    Avatar of youtubeYouTube·2y

    Go (fiber) vs. Go (stdlib) vs. Go (gin): Performance Benchmark in Kubernetes

    The post compares the performance of Golang HTTP frameworks—Fiber, Gin, and the Golang standard library—within a Kubernetes environment. By deploying the applications on an AWS cluster and measuring their CPU, memory usage, client-side latency, and requests per second, the test finds that Fiber performs best in terms of resource usage and latency. However, the standard library is recommended for general use due to its reliability and broad suitability for most applications.