Postlar filtri


Hello, dear community!

I wish you Merry Christmas 🎄 Happy New Year 🎊 and great winter holidays ahead!☃️ ❄️

See you in 2025 👋


Coming in Go 1.24: testing/synctest experiment for time and concurrency testing

Testing code that involves time or concurrency can be a struggle. It often leads to hard-to-debug flakes in CI or long-running tests.

Go 1.24 is scheduled to be released in February and the release freeze has begun.

It’s set to include an experimental testing/synctest package designed to make testing code that involves time or concurrency precise and fast.

https://danp.net/posts/synctest-experiment/


Go Blueprint: A Quick Way to Start Go Projects ⚒

The tool helps you setting up new Go projects fast, with ready-made templates and all the basic setup done for you.

While I’m not really into using tools like this, some might find it useful to save time and focus on development.

From the authors: "Powerful CLI tool designed to streamline the process of creating Go projects with a robust and standardized structure. Not only does Go Blueprint facilitate project initialization, but it also offers seamless integration with popular Go frameworks, allowing you to focus on your application's code from the very beginning."

https://docs.go-blueprint.dev/


Go sync.Map: The Right Tool for the Right Job

In Go, sync.Map offers a thread-safe alternative to traditional maps. While sync.Map can be highly effective in scenarios involving heavy concurrent access, it isn't always the best choice. In this article by VictoriaMetrics, you'll learn when to opt for sync.Map, how it differs from regular maps, and the performance trade-offs involved.

https://victoriametrics.com/blog/go-sync-map/index.html


The standard library of Go 1.23 now includes the new unique package. The purpose behind this package is to enable the canonicalization of comparable values. In other words, this package lets you deduplicate values so that they point to a single, canonical, unique copy, while efficiently managing the canonical copies under the hood. You might be familiar with this concept already, called “interning”.

Let’s dive in to see how it works, and why it’s useful.

https://go.dev/blog/unique


If you use Timer.Reset() in Go 1.22 or earlier, you may be doing it wrong. Even the book 100 Go Mistakes (which is usually right about Go nuances) got it wrong.

Let's see what the problem might be and how to work around it.

https://antonz.org/timer-reset/


Profile-guided optimisation (PGO) is a technique where CPU profile data for an application is collected and fed back into the next compiler build of Go application. The compiler then uses this CPU profile data to optimise the performance of that build by around 2-14% currently (future releases could likely improve this figure further).

In this article, the Grab tech folks show off their wins and learnings, along with the Dockerfile used to make it happen.

https://engineering.grab.com/profile-guided-optimisation

Enjoy!


Okay based on the first reactions it seemed like the naming convention issue brought by Zach didn't get much reflection in you.

In this case, I'd like to share a more practical guidance I used recently when had to test a k8s operator setup locally.

The topic is:
Go: Testing Kubernetes Applications with EnvTest

Enjoy 🙂

https://blog.marcnuri.com/go-testing-kubernetes-applications-envtest


"ok" considered harmful?

“Just like there’s an unwritten law that every error variable in Go must be named err, there’s an unwritten law that every map existence variable in Go must be named ok.”

But Zach thinks we can, and should, look at doing better.

https://www.dolthub.com/blog/2024-05-10-ok-considered-harmful/


https://go.dev/blog/chacha8rand

Explore the recent advancements in randomness within the Go programming language. Authors Russ Cox and Filippo Valsorda, part of the Go team, look closely at the complexities of addressing security requirements for specific use cases and the implementation of the ChaCha(Rand8) algorithm. Discover how these improvements have enhanced random number generation in Go, culminating in the seamless security enhancements introduced in Go 1.22.


Mastering Maps in Go: Everything You Need to Know

Maps, also known as associative arrays or hash tables, are vital data structures for solving algorithmic problems in programming. Understanding their features, operations, time and space complexities, and implementation in code is crucial for developers. With this knowledge and practical experience, developers can effectively apply maps to problem-solving scenarios.

This article offers a comprehensive guide to using maps, covering their overview, implementation in Go programming, and strategies for using them in concurrent code.


The Impact of Pre-Allocating Slice Memory on Performance — The author wanted to establish, in numbers, how pre-allocating memory improves performance using quantitative measurements and tools for automated detection.


Initial Thoughts on Go 1.22 — 1.22 is due next month, but the release candidate gives us a look at plenty of changes and improvements coming down the pike, including new default behavior for loop variables in for loops, the ‘rangefunc’ experiment (more on that next), and even some performance improvements.

https://www.dolthub.com/blog/2024-01-12-golang-1-22rc/




Logging in Go: A Comparison of the Top 8 Libraries

There's probably a 99% chance that if you're logging in Go, you're using a third-party logging framework since the built-in log package lacks even the most basic features required for production logging. This recently changed with the release of Go 1.21 where the new log/slog package for structured, leveled, and context-aware logging was one of the major highlights.

https://betterstack.com/community/guides/logging/best-golang-logging-libraries/


Go Sync or Go Home: WaitGroup

Go’s goroutines, channels, and mutexes make it easy to develop complex concurrency systems. Most problems can be solved using these three mechanisms, but you might be asking yourself — what else is out there?

https://medium.com/@yardenlaif/go-sync-or-go-home-waitgroup-5f074a03776e


Video oldindan ko‘rish uchun mavjud emas
Telegram'da ko‘rish
Memory leaks can be a significant issue in any programming language, and Go is no exception. Despite being a garbage-collected language, Go is still susceptible to memory leaks, which can lead to performance degradation and cause your operating system to run out of memory.
To defend itself, the Linux operating system implements an Out-of-Memory (OOM) killer that identifies and terminates processes that consume too much memory and cause the system to become unresponsive.
In this blog post, we’ll explore the most common causes of memory leaks in Go and demonstrate how to use Grafana Pyroscope, an open source continuous profiling solution, to find and fix these leaks.

https://grafana.com/blog/2023/04/19/how-to-troubleshoot-memory-leaks-in-go-with-grafana-pyroscope/


User or *User - Do We Need Struct Pointers Everywhere?

The answer, as you might’ve guessed, is “no.” But, it’s also more nuanced due to the lifetime of a struct, its usage, and other aspects that boil this down to general guidelines and case-by-case analysis.

https://preslav.me/2023/02/06/golang-do-we-need-struct-pointers-everywhere/


Error handling in Go is a little different than other mainstream programming languages like Java, JavaScript, or Python. Go’s built-in errors don’t contain stack traces, nor do they support conventional try/catch methods to handle them. Instead, errors in Go are just values returned by functions, and they can be treated in much the same way as any other datatype - leading to a surprisingly lightweight and simple design.

In this article, Brandon Schurman demonstrates the basics of handling errors in Go, as well as some simple strategies you can follow in your code to ensure your program is robust and easy to debug.

https://earthly.dev/blog/golang-errors/



20 ta oxirgi post ko‘rsatilgan.