golang | Unsorted

Telegram-канал golang - Go

19188

// admin @denniselite // Denis Podlesnykh, a Golang Engineer go func() { channel <- news }() news := <-channel fmt.Sprintf("%s", news)

Subscribe to a channel

Go

If you’re working with Go and care about performance, then check out the https://goperf.dev/

Here you can find not theoretical, but practical patterns applicable to memory issues, concurrency, and overall, real bottlenecks you hit in production.

The guide has been recently updated with more depth (atomics, concurrency trade-offs, etc.), so worth revisiting even if you’ve seen it before.

Solid reference to keep bookmarked. Enjoy!

Читать полностью…

Go

Hello, folks, it's been a while. Re-sharing an interetsting recording from GopherCon 2025:
Advancing Go Garbage Collection with Green Tea (youtube). TL;DR:

Go 1.25 includes a new experimental garbage collector called Green Tea, available by setting GOEXPERIMENT=greenteagc at build time. Many workloads spend around 10% less time in the garbage collector, but some workloads see a reduction of up to 40%!

There is an also official text version on the Green Tea Garbage Collector if one does not like to watch the video.

Thanks!

Читать полностью…

Go

What's new in Go: Google I/O presentation

https://www.youtube.com/watch?v=kj80m-umOxs&amp;ab_channel=GoogleforDevelopers

Читать полностью…

Go

Hello, dear community!

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

See you in 2025 👋

Читать полностью…

Go

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

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

Читать полностью…

Go

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!

Читать полностью…

Go

"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/

Читать полностью…

Go

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.

Читать полностью…

Go

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/

Читать полностью…

Go

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

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/

Читать полностью…

Go

A bit of a clickbait title, but still an interesting finding: https://hmarr.com/blog/go-allocation-hunting/

Читать полностью…

Go

Breaking the Monolith at Twitch: Part One

Twitch is one of a large group of successful companies that began life running as a monolithic Ruby on Rails app but they’ve written about where they went from there, how Go entered the picture, and their current practices.

About the Author: My name is Mario Izquierdo, and I’ve been a Full Stack Engineer at Twitch since 2017. I’ve worked in a variety of systems in my time here, including the public API, infrastructure, and tools for services.

From the author: This is Part One (of two) of our story chronicling Twitch’s journey from monolithic architecture to microservices. In Part One, you’ll learn about our early days, from our rapid growth to the performance bottlenecks that pushed us to find better solutions. Part Two, covers “Wexit,” our migration to microservices and all the challenges and benefits that came with the switch.

https://blog.twitch.tv/en/2022/03/30/breaking-the-monolith-at-twitch/

Enjoy! 🤩

Читать полностью…

Go

Go 1.18 is released!

The Go Team
15 March 2022


Today the Go team is thrilled to release Go 1.18, which you can get by visiting the download page.

Go 1.18 is a massive release that includes new features, performance improvements, and our biggest change ever to the language. It isn’t a stretch to say that the design for parts of Go 1.18 started over a decade ago when we first released Go.

Generics
In Go 1.18, we’re introducing new support for generic code using parameterized types. Supporting generics has been Go’s most often requested feature, and we’re proud to deliver the generic support that the majority of users need today. Subsequent releases will provide additional support for some of the more complicated generic use cases. We encourage you to get to know this new feature using our generics tutorial, and to explore the best ways to use generics to optimize and simplify your code today. The release notes have more details about using generics in Go 1.18.

Fuzzing
With Go 1.18, Go is the first major language with fuzzing fully integrated into its standard toolchain. Like generics, fuzzing has been in design for a long time, and we’re delighted to share it with the Go ecosystem with this release. Please check out our fuzzing tutorial to help you get started with this new feature.

Workspaces
Go modules have been almost universally adopted, and Go users have reported very high satisfaction scores in our annual surveys. In our 2021 user survey, the most common challenge users identified with modules was working across multiple modules. In Go 1.18, we’ve addressed this with a new Go workspace mode, which makes it simple to work with multiple modules.

20% Performance Improvements
Apple M1, ARM64, and PowerPC64 users rejoice! Go 1.18 includes CPU performance improvements of up to 20% due to the expansion of Go 1.17’s register ABI calling convention to these architectures. Just to underscore how big this release is, a 20% performance improvement is the fourth most important headline!

For a more detailed description of everything that’s in 1.18, please consult the release notes.

Go 1.18 is a huge milestone for the entire Go community. We want to thank every Go user who filed a bug, sent in a change, wrote a tutorial, or helped in any way to make Go 1.18 a reality. We couldn’t do it without you. Thank you.

Enjoy Go 1.18!

Читать полностью…

Go

Are Atomic Operations Faster and Better Than a Mutex? It Depends

From the author:
"Recently, while reviewing a pull request, a discussion arose about using sync/atomic versus sync.RWMutex.
It’s a question that comes up often when writing concurrent Go code, so I thought it would make a great post"

https://madflojo.dev/posts/are-atomic-operations-faster-than-a-mutex/

Читать полностью…

Go

Be Careful with Go Struct Embedding

Embedding structs can quietly mask deeper-nested fields: a duplicate field name isn’t ambiguous unless it appears at the same ‘depth’, meaning your program may choose an unintended value.

https://mattjhall.co.uk/posts/be-careful-with-go-struct-embedding.html

Читать полностью…

Go

Go 1.24: A Major Improvement for Tooling: go tools 🛠

Hello, folks! The upcoming Go 1.24 (supposed to be coming this month, Feb 2025) introduces a new go tool command, aiming to significantly improve the way project-specific tools are managed. This update eliminates the need for the tools.go workaround, reduces dependency bloat, and improves performance through caching. So,
- No more tools.go hacks
- Faster execution with caching
- Cleaner and more efficient dependency management

How it works? Simple!

Add a tool:


go get -tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.4.1

Run it:

go tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen --config=config.yaml openapi.yaml

List available tools:

go tool


Some people say this is one of the most useful changes to Go's tooling in years, making project setups more efficient and maintainable, so take a look in more details here https://www.jvt.me/posts/2025/01/27/go-tools-124/ 🚀

PS More official docs can be found in the Go 1.24's release notes here: https://tip.golang.org/doc/go1.24#tools

Читать полностью…

Go

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

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

Читать полностью…

Go

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/

Читать полностью…

Go

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

Читать полностью…

Go

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.

Читать полностью…

Go

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.

Читать полностью…

Go

https://threedots.tech/post/making-games-in-go/

Miłosz uses the much loved Ebitengine to create a simple Asteroids game. There’s a lot to cover, but the steps are small and easy to digest if you’re looking to understand how games are made.

Читать полностью…

Go

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/

Читать полностью…

Go

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/

Читать полностью…

Go

Backward compatibility in Go: discussion

>>>
We now have about ten years of experience with Go 1 compatibility.

In general it works very well for the Go team and for users. However, there are also practices we've developed since then that it doesn't capture (specifically GODEBUG settings), and there are still times when users’ programs break.

I think it is worth extending our approach to try to break programs even less often, as well as to explicitly codify GODEBUG settings and clarify when they are and are not appropriate.
>>>

by Russ Cox

Join the discussion if you wish https://github.com/golang/go/discussions/55090

Читать полностью…

Go

Hello everyone 👋

Today’s post is about finding Golang jobs abroad.

A friend of mine is operating developer job board Relocate.me. The project is built around and focused entirely on tech jobs that offer visa sponsorship/relocation assistance.

If working abroad is smth you're interested in, consider checking it out.

Here's a link to the Golang jobs that are currently on offer - https://relocate.me/search/golang

Also, subscribe to their Telegram channel to get alerts of new jobs - @relocateme

Читать полностью…

Go

When More Parallelism != More Performance

This is an important reading especially for beginners in Go to understand the pros and especially the cons of parallel computing in Go. The post shows by example how concurrency could lead into a bad performance and what one should pay attention to when working on concurrent/parallel computing

https://convey.earth/conversation?id=44

Читать полностью…
Subscribe to a channel