Best of GolangJuly 2024

  1. 1
    Article
    Avatar of gcgitconnected·2y

    I Built a 2D Game in 40 Minutes with Ebiten

    A business analyst who has led multiple development teams shares their experience of building a 2D game called 'Scorpions and Ferraris' in 40 minutes using Golang and the Ebiten library. The game, inspired by Frogger, features a scorpion avoiding cars to reach the other side of the screen. The post includes detailed steps for setting up the development environment, creating the game structure, and implementing game logic. Additionally, it discusses the use of Paint.net for modifying graphics.

  2. 2
    Article
    Avatar of lobstersLobsters·2y

    Scaling One Million Checkboxes to 650,000,000 checks

    One Million Checkboxes (OMCB) is a website that scaled from a few expected users to over 650 million checks within days. The architecture involved using Redis for state management, nginx for static content and reverse proxy, and Flask for API handling. The site faced several challenges including unexpected high traffic, Redis connection issues, and bandwidth costs. Solutions included adding more servers, batching updates, using a connection pool, and eventually rewriting the backend in Go, which significantly improved performance. The project emphasized learning and fun over perfect solutions, leading to valuable scaling insights.

  3. 3
    Article
    Avatar of itnextITNEXT·2y

    Performance Benchmarking: gRPC+Protobuf vs. HTTP+JSON

    A performance benchmarking experiment compared gRPC with Protocol Buffers to HTTP with JSON for microservices communication in Go. The tests, run on a local machine, showed that HTTP/2 was slower than gRPC, which in turn was slower than HTTP/1. Despite these results, Protocol Buffers over gRPC remain an effective choice for inter-service communication due to its structured format.

  4. 4
    Article
    Avatar of devtoDEV·2y

    Go and MongoDB: Building a CRUD API from Scratch

    Learn to build a basic CRUD API using Go and MongoDB, including setup, project structure, model definition, MongoDB connection, and API handlers for create, read, update, and delete operations. Detailed code examples and tips for error handling, security, and database design are provided to help you successfully develop a scalable and efficient web application.

  5. 5
    Article
    Avatar of communityCommunity Picks·2y

    6 unique and lesser-known Go techniques

    This post explores six unique and lesser-known techniques in Go (Golang): the use of the go generate command for automating code generation, the power of build tags for conditional compilation, the Functional Options pattern for flexible configuration, error wrapping for enhanced error context, the use of context for managing cancellations and timeouts, and JSON tagging for precise control over data marshaling and unmarshaling. These techniques help in writing more efficient, idiomatic, and maintainable Go code.

  6. 6
    Article
    Avatar of awegoAwesome Go·2y

    How I sent 500 million HTTP requests to 2.5 million hosts

    An individual leveraged Go's simplicity and concurrency to send 500 million HTTP/1.1 requests to 2.5 million hosts for an ethical hacking use case. By utilizing Kubernetes for horizontal scaling and optimizing both code and libraries, they achieved this massive scale efficiently. Key optimizations included pre-resolving DNS, hand-crafting HTTP requests, and using the fasthttp library.

  7. 7
    Article
    Avatar of communityCommunity Picks·2y

    A JavaScript developer tries Go for the first time

    A software developer with extensive JavaScript experience shares his first impressions on learning Go. Highlights include Go's approach to error handling with errors as values, the utility of defer statements for resource management, and the requirement for explicit type conversion. The developer appreciates Go's simplicity, readability, and the fact that it enforces one way to do things, which is beneficial for large teams working on complex codebases.

  8. 8
    Article
    Avatar of hnHacker News·2y

    yunginnanet/HellPot: HellPot is a cross-platform portal to endless suffering meant to punish unruly HTTP bots.

    HellPot is a cross-platform honeypot designed to trap and punish rogue HTTP bots by sending them endless streams of data. Implemented in Go, it uses a toml configuration file, JSON logging, and offers substantial performance gains. When misconfigured or when bots ignore the standard `robots.txt`, HellPot subjects them to an eternity of useless data generated by a Markov engine. It has easy setup steps and integrates well with web servers like nginx and Apache.

  9. 9
    Article
    Avatar of communityCommunity Picks·2y

    Programming Languages that Developers should Explore in 2024-2025: Stay Ahead of the Curve

    Developers should explore languages like TypeScript, Golang, Python, and Zig to stay ahead in 2024-2025. TypeScript's static typing and compatibility with frameworks like Angular, React, and Vue.js make it essential for scalable JavaScript applications. Go excels in building high-performance network applications and microservices due to its concurrency features and fast compilation times. Python remains crucial in AI, ML, web development, automation, and scripting. Zig provides C-like performance with modern features and improved safety, ideal for cross-platform applications.

  10. 10
    Article
    Avatar of antonzAnton Zhiyanov·2y

    Gist of Go: Concurrency

    An interactive book on Go concurrency offers practical exercises to teach goroutines, channels, and other concurrency tools from the ground up. Targeted at experienced Go programmers, it includes 44 browser-based exercises and runs on Go version 1.22. The book aims to publish all chapters by the end of 2024.

  11. 11
    Article
    Avatar of antonzAnton Zhiyanov·2y

    Gist of Go: Goroutines

    This post explores Go's concurrency model focusing on goroutines. It demonstrates how to write and run concurrent programs with goroutines, manage their execution using WaitGroups, and exchange data via channels. The post covers the importance of separating concurrency logic from business logic and introduces basic patterns like producer-consumer with goroutines. Interactive examples and exercises help solidify understanding.

  12. 12
    Article
    Avatar of communityCommunity Picks·2y

    gRPC fundamentals with Go

    gRPC is a powerful tool for establishing robust and scalable communication between server applications. This post explores using gRPC with Go through a practical example of a coffee shop, demonstrating how to define messages using Protocol Buffers, generate code, implement a server, and create a client. Key advantages of gRPC over REST APIs include type safety, performance optimization, and efficient handling of large data transfers through features like streaming RPCs.

  13. 13
    Article
    Avatar of communityCommunity Picks·2y

    If Google No Longer supports Golang

    Recent layoffs at Google have sparked concerns about the future of the Go programming language. With Google laying off key developers from other projects, there's speculation about Go's fate. Potential scenarios include the dissolution of the Go core team, rebranding by Google, or a transition to an external foundation like CNCF. Despite these concerns, Go’s current attachment to Google Cloud and its focus on customer success suggest that immediate shutdown is unlikely. The language might transition to a nonprofit organization, drawing parallels to Rust's journey from Mozilla.

  14. 14
    Article
    Avatar of awegoAwesome Go·2y

    The value of API-First design on side-projects

    API-First design prioritizes the development of APIs before implementing other parts of a software system. It places the API at the center of the development process, facilitating the creation of a well-designed and consistent API that serves as the foundation for the entire application. By using tools like OpenAPI Specification, developers can generate backend and frontend code, ensuring better synchronization and saving time. This method leads to improved development speed, reduced errors, and better API documentation, making it a highly beneficial approach for side projects.

  15. 15
    Article
    Avatar of antonzAnton Zhiyanov·2y

    Go 1.23: Interactive release notes

    Go 1.23 introduces several key features and improvements. Iterators are now more robust, offering a standard way to work with sequences of values. The update improves garbage collection and the stop/reset behavior of timers. There's also a new package for canonicalizing values, enhancements in HTTP cookie handling, and a function for copying directories. Other notable changes include telemetry collection tools and runtime adjustments for better error messaging and compiler efficiency.

  16. 16
    Article
    Avatar of devtoDEV·2y

    How I build simple Mac apps using Go

    DarwinKit has released v0.5.0, the largest release to date, offering near-complete coverage of 33 Apple frameworks with automatic Go integration. This includes 2,353 classes, 23,822 methods, 9,519 constants, and 543 structs. It's now possible to build simple Mac apps using Go without XCode, thanks to features like automatic conversion of native Go types, block arguments support, and pre-made delegate implementations. The project aims to eventually cover Apple framework functions and minimize CGO usage to enhance build times and binary sizes.

  17. 17
    Article
    Avatar of gcgitconnected·2y

    Why and how you should rate-limit your API

    Rate limiting is essential for managing traffic, controlling costs, and providing a smooth user experience for APIs. It involves setting request limits per time period to handle traffic loads efficiently. Key rate limiting policies like fixed window, sliding window, token bucket, and leaky bucket have specific use cases and trade-offs. Implementation can be done at proxy or application levels, providing different degrees of control. The article walks through setting up a rate limiting service using Go, Redis, and the leaky bucket policy, emphasizing practical tips and the importance of monitoring and adjustments.

  18. 18
    Article
    Avatar of phProduct Hunt·2y

    KubeNodeUsage - Kubernetes Node Usage Visualizer - Terminal App Built on GO

    KubeNodeUsage is a terminal application built with Go that visualizes Kubernetes node usage. It is an open-source developer tool featured on GitHub and launched for the first time on July 16th, 2024.

  19. 19
    Article
    Avatar of awegoAwesome Go·2y

    EchoVault: Embeddable Redis Alternative in Go

    EchoVault is an open-source, embeddable in-memory datastore designed for Go applications, offering a RESP-compatible interface over TCP. It aims to replace traditional in-memory data stores like Redis, eliminating the overhead of separate management and deployment. Key features include TLS support, RAFT-based replication, various data structures, and access control. EchoVault supports both standalone and clustered deployments, making it suitable for use cases like in-memory caching, service discovery, session management, real-time analytics, and more.

  20. 20
    Article
    Avatar of lobstersLobsters·2y

    gRPC Over HTTP/3

    HTTP/3 offers a range of benefits for gRPC services, including faster connection establishment, eliminating head-of-line blocking, and mandatory encryption via TLS 1.3. The post explores the practical implementation of gRPC servers and clients over HTTP/3 using Go's ConnectRPC and quic-go libraries. HTTP/3 leverages QUIC, a protocol built on UDP, to reduce latency and improve performance. Despite the early adoption phase, the potential for enhanced performance and security in API development is evident. Practical examples and experimentation reveal current capabilities and limitations of gRPC over HTTP/3.

  21. 21
    Article
    Avatar of communityCommunity Picks·2y

    Dealing with Race Conditions: A Practical Example

    The post describes a practical example of dealing with race conditions in an application managing on-call shifts for doctors. It explains how naive API implementations can lead to race conditions and demonstrates two PostgreSQL-based solutions—serializable transaction isolation and advisory locks—to handle these issues. The article includes SQL snippets and code examples for implementing these solutions and discusses the importance of addressing race conditions in various real-life scenarios.

  22. 22
    Video
    Avatar of awesome-codingAwesome·2y

    What Happened in June?

    In June, several notable developments occurred in the dev world. The State of JavaScript survey revealed that Vue has surpassed Angular to become the second most used front-end framework, while React remains the most popular. Next.js leads the meta-framework space, with Astro showing potential as an alternative. Significant releases included Vue's 3.12 update, Astro's 4.10 version, the ECMAScript 2024 specification, Go's next release candidate, and TypeScript's version 5.5, which introduced various new features aimed at improving developer experience and language capabilities.

  23. 23
    Article
    Avatar of communityCommunity Picks·2y

    Atomic operations composition in Go

    Atomic operations in a concurrent program are beneficial because they often translate into a single processor instruction, eliminating the need for locks. However, misusing atomic operations can lead to unpredictable results. The post explores various examples of atomic operations in Go and demonstrates why their composition does not guarantee atomicity. It emphasizes the importance of cautious use of atomics and suggests that mutexes might lead to fewer concurrency-related errors.

  24. 24
    Video
    Avatar of codeheimcodeHeim·2y

    #44 Golang - Mastering Kafka with Golang: A Beginner's Guide

    Learn how to use Apache Kafka with Golang by building a coffee order and brewing system. The guide covers setting up a Kafka producer to send coffee orders and a consumer to process these orders. It uses the Sarama library for Kafka integration, demonstrating how to handle HTTP requests, serialize data to JSON, and manage Kafka messages in a Golang application.

  25. 25
    Article
    Avatar of communityCommunity Picks·2y

    plutov/ultrafocus: CLI tool to block distracting websites and boost productivity.

    Ultrafocus is a CLI tool designed to block distracting websites and enhance productivity. Users can customize their blacklist and easily focus on tasks by modifying the `/etc/hosts` file. The tool supports macOS, Linux, and Windows, and installation can be done via downloading the latest binary or using `go install`.