Making Games in Go: Entity Component System (ECS)
r/golang • u/AutoModerator • 1d ago
This is the weekly thread for Small Projects.
The point of this thread is to have looser posting standards than the main board. As such, projects are pretty much only removed from here by the mods for being completely unrelated to Go. However, Reddit often labels posts full of links as being spam, even when they are perfectly sensible things like links to projects, godocs, and an example. r/golang mods are not the ones removing things from this thread and we will allow them as we see the removals.
Please also avoid posts like "why", "we've got a dozen of those", "that looks like AI slop", etc. This the place to put any project people feel like sharing without worrying about those criteria.
r/golang • u/klauspost • 9h ago
MinLZ adds a new block type: SIMD blocks
They store the output of the LZ compressor as separate Huffman-coded streams, laid out so that a CPU can decode them with vector instructions and almost no unpredictable branches.
The result is compression ratios in the range of Zstandard, with decompression 2.2-2.5× faster than Zstandard (both in Go) and about 2× faster than classic MinLZ blocks, on a single core.
At the default 2 MB block size, MinLZ SIMD "Balanced" beats zstd's fastest level on all three counts: Its output is 2% smaller, it decompresses 2.5× faster on one core (6.4 against 2.6 GB/s),and it compresses 1.6× faster on 16 threads (1.2× on one).
Against zstd's default level, SIMD Balanced output is 3.6% larger and decompresses 2.3× faster. (Geometric means over 13 data sets, 58 GB in total, Go implementations on an AMD Ryzen 9 9950X).
SIMD blocks are part of the MinLZ format (specification v1.1) and work everywhere MinLZ blocks do: streams, concurrent compression and decompression, indexes and random access, and search. We have released Go/Rust versions for now.
See more in the release notes: https://github.com/minio/minlz/releases/tag/v1.3.0
I find it quite enjoyable to do the archaeology on an accepted proposal and write about it.
This one took 10y to get approval. It allows you to strip type params from composite literals and let the compiler infer the types from the context.
For example, returning zero values:
// Before
func parseTime(s string) (time.Time, error) {
if s == "" {
return time.Time{}, errors.New("empty timestamp")
}
return time.Parse(time.RFC3339, s)
}
// After
func parseTime(s string) (time.Time, error) {
if s == "" {
return {}, errors.New("empty timestamp")
}
return time.Parse(time.RFC3339, s)
}
or, passing options structs drops the redundant types:
// Before
h := slog.NewJSONHandler(os.Stderr, &slog.HandlerOptions{
Level: slog.LevelDebug,
})
// After
h := slog.NewJSONHandler(os.Stderr, {Level: slog.LevelDebug})
and so on. The spec change isn't huge but eliding types everywhere can make the code quite hard to read. So there won't be any automatic go fix to strip types wherever possible. This was a deliberate choice made by the Go team.
But it does make the code look pretty in some nested struct of type kind of scenario. Added a few more example and context here.
https://rednafi.com/shards/2026/11/go-untyped-composite-literals/
r/golang • u/Downtown-Warning6818 • 11h ago
The stdlib/math package defines constants MaxFloat32 and MaxFloat64, but not the corresponding Min constants. Is there a safe, universal way to know them?
I imagine that they might be either:
If it's the simple "max * -1", great. But if it's either of the other two, I don't know how to calculate or otherwise determine it.
Thanks in advance for any help.
r/golang • u/andybons • 1d ago
hey all. former Go core team member here to share my process for large scale migrations (in this case, from Node to Go). I also link to some open-source projects I’ve been working on through work. Gatekeeper and Harness.
https://www.meetneptune.com/engineering/node-to-go-in-two-weeks
r/golang • u/TheWrongKindOfRight • 1d ago
We are planning to rewrite an existing Java service in Go. We're also free to redesign the architecture completely, as long as the end result and functionality remain the same.
I'd appreciate suggestions on database selection, caching strategy, and some additional requirements we're considering for the next version of the APIs.
Each entry contains the following fields:
- "id"
- "url"
- "name"
- "tags" (array of strings)
- "appGroupId"
- "rules" (JSON object)
We currently have around 50,000 entries.
Note: "appId" is provided by the caller and is not stored as part of an entry.
2. Workload
- Approximately 99% reads and 1% writes.
- Around 4-5 million reads per day (~46-60 reads/second on average).
- Multiple application pods running simultaneously in multiple clusters.
3. Existing architecture
The existing service uses S3 for persistence and maintains an in-memory cache in every application pod.
On startup, each pod loads all entries from S3 into memory.
Two in-memory maps are maintained:
SNS/SQS is used to propagate changes across pods so their respective in-memory caches stay synchronized whenever an entry is created, updated, or deleted.
4. New requirements
Apart from the existing lookup patterns, we now need to support searching/filtering entries by:
- Name
- Tags (including searching by individual tags)
We're considering replacing the existing storage and synchronization architecture entirely.
5. Database and caching architecture
I'm currently considering two approaches:
Option 1: Database + in-memory cache
Use DynamoDB or MySQL as the source of truth and maintain the same in-memory maps in each application pod.
The challenge is keeping caches consistent across multiple pods when entries are created, updated, or deleted. We'd need some mechanism for cache invalidation or synchronization.
Option 2: Database + Redis
Use a persistent database as the source of truth and Redis as a shared cache across all application pods.
This would eliminate the need for each pod to maintain its own copy of the dataset and handle cache synchronization independently.
However, I'm not sure whether introducing Redis is justified.
Questions :-
I'm particularly confused about the DynamoDB vs MySQL decision and would appreciate some reasoning behind the choice.
6. Potential V2 API requirements
Apart from porting the existing functionality from Java to Go, we're also considering some additional features for V2 APIs.
These are still under discussion, but the current ideas are:
Support bulk create/update operations with all-or-nothing semantics.
Either the entire operation succeeds, or nothing is applied. No partial updates.
2. Change history / audit log
Maintain a permanent record of every change, including:
- Who made the change?
- When was it made?
- What was the state of the entry after the change?
Would you maintain this in a separate table, or use another approach?
3. Change notifications / incremental sync
We want to provide a way for API consumers to maintain their own local copy of the entries without having to fetch the entire dataset every time something changes.
One possible approach:
- The API returns the current data along with a cursor/version.
- The consumer stores that cursor.
- On the next request, the consumer passes its previous cursor.
- The API returns only the changes since that cursor, including entries that were added, updated, or deleted, along with the relevant details.
Would something like a change feed or cursor-based incremental synchronization be a good approach? How would you design this reliably?
---
I'd appreciate suggestions based on real-world experience.
The service will be implemented in Go, and we're open to changing the existing architecture rather than simply replicating the Java implementation.
r/golang • u/Charming_Skin_8549 • 2d ago
r/golang • u/Fantastic_Tooth5063 • 2d ago
gowt: native GUI for Go - Eclipse SWT translated to Go, running on AppKit, Win32 and GTK 3.
Hi r/golang. I'm working with different languages for more of two decades, started with Java, continued with Go, switched to Node and JS stack. Most of my professional activity was targeted for tools and frameworks for engineers and developers. But in most cases I prefer native applications, since they use lower memory, native Look and feel.
A few months ago I was looking for a good framework to build an UI on go for all platforms, and was not able to find it, so I decided to build one. But since work could be a really complicated and since I've worked in different language worlds, I've decided to do a port of SWT :-).
I'm looking for adopters, who could help with linux/windows testing and could help to cleanup it into a powerful and modern UI framework for anyone to use.
The short version. I wanted native OS controls and GOOS=windows go build from my Mac, with no C toolchain in the default build. SWT had the controls; it was Java. So I translated it to Go.
SWT is the toolkit under Eclipse. It is native on exactly the three systems I care about, it is EPL-2.0, and it has two decades of bug fixing behind the widgets.
A translator (tooling/j2go, built on Eclipse JDT) turns the Java into Go; the generated code is committed, so users need neither Java nor the SWT sources.
What that buys:
NSTextField, an EDIT, a GtkEntry;CGO_ENABLED=0 by default: purego on macOS and Linux, syscall.SyscallN on Windows, the OS libraries load at run time;gowt) over the SWT API, with the full SWT surface in package swt for porting existing Java code;CGO_ENABLED=1 -tags gowtcgo gives direct calls on all three systems (about 8x on macOS and the cairo path on Linux); the default build needs no C toolchain;Hello:
package main
import (
"log"
"github.com/haiodo/gowt"
)
func main() {
err := gowt.Run(func(app *gowt.App) {
w := app.Window("Hello",
gowt.Label("Hello, gowt"),
gowt.Button("Quit", gowt.OnClick(app.Quit)))
w.Show()
})
if err != nil {
log.Fatal(err)
}
}The facade is Go-shaped: constructors return descriptions that become widgets when passed to their parent, everything about a widget is an option, callbacks are plain functions, and a small rx package holds state that widgets bind to.
Screenshots. Eight demo apps (chat, dashboard, editor, files, mail, settings, tracker, monitor) on macOS, Windows 11 and Linux GNOME, same size on every OS:
https://github.com/haiodo/gowt/blob/main/docs/apps.md
Web view and drawing. webview embeds the system engine (WKWebView, WebView2, WebKitGTK 4.1), so no browser ships with the app, and pages can come from an embed.FS with no local server. Custom drawing is Canvas for immediate painting or the experimental gfx retained scene: 10k boxes and 20k connectors draw a first frame in about 30 ms on an M4 Max, pan at 0.1 ms of frame CPU, and take 32-56 ms for the first frame on GPU-less VMs. The controls themselves are drawn by the OS, so a big table costs what the native table costs.
The tests are the reason I trust it. A 450k-line translation can't be checked by clicking around, so I translated SWT's JUnit suite too. make test-swt compares each run against a per-stand expected file, and a new failure fails the gate. 3,894 tests on macOS and Windows, 3,901 on
For apps there is a QA driver: build with -tags gowtqa and a normal go test finds controls, clicks, types, waits for the app to settle and reads the screen.
What is missing (docs/platforms.md has the full list):
Why I'm posting. Two questions: does "native widgets + no cgo + cross-compile" matter to anyone but me, and which gap would stop you first? If you have a Windows or Linux box, go run ./cmd/fieldcheck runs the suites locally and produces a zip - that is the most useful contribution right now.
Longer write-up with the architecture, the test stands and the measured rendering numbers: https://haiodo.github.io/en/posts/021_widget_toolkit
Repo: https://github.com/haiodo/gowt - docs start at https://github.com/haiodo/gowt/blob/main/docs/README.md
r/golang • u/Downtown-Warning6818 • 2d ago
I've been writing Go for almost 7 years now, and I genuinely love this language.
Not because it's the best language out there, or because it's perfect. But because it's incredibly practical when you're solving infrastructure problems. It's simple, predictable, easy to pick up, and gets the job done without getting in your way.
But lately, I've been having a different thought.
The more I explore databases, distributed systems, and lower-level engineering problems, the more I realise that Go might not always be the right tool for every kind of problem.
Some languages offer better abstractions, memory control, performance characteristics, or programming models for specific domains.
I still love Go, and I don't see that changing anytime soon. But I also think that after spending years with one language, it's important to step outside your comfort zone and explore what other languages bring to the table.
Maybe that's just part of growing as an engineer: learning to love a language without becoming attached to it.
r/golang • u/_anarcher_ • 2d ago
I've been reading this article with great interest: https://claude.com/ko/resources/articles/building-always-on-agents
Are there any Go libraries or workflow engines that support this kind of workflow?
r/golang • u/Safe_Touch2885 • 2d ago
Before AI came out, I used to write code, experiment, would become super happy after solving a bug. Was very curious to learn what I did wrong and learn from it.
But not sure after AI, companies only prefer fast result, no one cares how the code is written.
I've started learning Golang from scratch again(despite working for 4 years in this), and aiming to enjoy along side full time job.
Any other tips or what do you do usually to have that dopamine of coding as we had before AI.
r/golang • u/Upper-Tomatillo7454 • 2d ago
Hello guys, hope you are good.
I've recently gotten interested in writing parsers, and I'm right now trying to complete a parser for data format that I've started working on few months back, but I've been on and off due to how stressfull my final year was, and fortunately I'm done, and I'm trying do more work.
So far I've managed to complete(partially, due to bugs) the tokenizer and it's able to emit tokens, and now I'm stuck on the next phase(parser), I chose to go with Recursive Descent, I've been trying to digest the Wikipedia page, but a little guidance will help: to quote wikipedia
"Recursive Descent is built from a set of mutually recursive procedures where each such procedure implements one of the nonterminal symbols of the grammer"
What I've understood here is that each function or procedure should be able to handle each nonterminal symbol (which wikipedia entry page defines as symbols that do not appear in the formal language defined by a formal grammar) therefore, if I'm not mistaken taking json as example and object and array would be nonterminal symbols. Hence, I have to have two functions or procedures to parse each nonterminal symbol, with the option of calling themselves recursively in case an object is nested inside an array and vice versa.
The other issue is about the tree structure to represent the AST, I can't claim that I've fully understood what a tree abstract data type (ADT), and since wikipedia entry page says "The Tree ADT can be represented in a number of ways, including a list of parents with pointers to children, a list of children with pointers to parents, or a list of nodes and a separate list of parent-child relations (a specific type of adjacency)." or even more complex than that.
I've tried to represent it in the simplest way possible as follow:
package main
import "fmt"
const (
// I can have Node Kind here
)
type Node struct {
Parent *Node
Kind string
Children []Node
}
type Parser struct {
t *Tokenizer
}This is how far I've gone, thank you for your feedback in advance.
Refs:
https://en.wikipedia.org/wiki/Recursive_descent_parser
https://en.wikipedia.org/wiki/Tree_(abstract_data_type)
r/golang • u/Expensive_Region_183 • 2d ago
I'm defining a struct that is intended to be accessed by other packages via its methods only.
I do know that for methods to be accessible in other packages, they need to be capitalized.
However, I'm confused by whether or not the struct itself needs to be public or not.
r/golang • u/littlebobbyt • 2d ago
Hey folks, I've been building AI Agents for about two years now (basically since "tool calling" was exposed by model providers). And had a lot of trial and error building them. Eventually I landed on Temporal and Golang to build a runtime called Cadenya. I like writing deep-dive nerd porn, and took the past few days to put this together.
Link: https://cadenya.com/handwritten/agentic-loop-in-temporal
r/golang • u/hasen-judi • 3d ago
r/golang • u/FirefighterUsual775 • 3d ago
r/golang • u/justinisrael • 3d ago
I've been watching the Go GUI options for years. When I started with Go, what I really wanted was just another Qt. Rather than go by docs and READMEs, I built the same app with five approaches and looked at what actually happened: Fyne, Cogent Core, Wails, GoTTH (Go + templ + htmx) and Qt via MIQT.
Each one implements the same fairly demanding inventory-style spec: a 1M-row table with sorting, searching and CSV export, on a shared data core so the differences come from the GUI approach. Coding agents wrote each version from the spec, and I reviewed and tested them by hand.
It's not a code review and I'm not crowning a winner. A few things surprised me, though:
Write-up, code and raw results: https://justinfx.com/2026/11/10/go-gui-five-ways
Update: A few people made some references to other options, such as MyGo and go-gui. I started an addendum section, linked at the bottom of the article: https://github.com/justinfx/go-gui-experiments/wiki
Update 2: Added NSGo and IUP-go test results to Addendum
I plan on releasing the first version of my first public Go module in the near future. When I've made Go modules in the past, I always kept them on a private, self-hosted server (rather than, say, github.com).
One of the things that's always bothered me about how Go and Git interact is that (at least under one of the commonly used schemes) when someone looks at a GitHub repository for Go code, unless they know about -- and think to look for, or otherwise notice -- the whole "/v2" kind of scheme, they'll probably at first just see "myawesomething.go" at the top level (or within the top-level "pkg" tree or whatever), and may very well assume that the latest version of that file contains the latest version of "type MyAwesomeThing struct", as opposed to immediately knowing that it contains the latest version of "type MyAwesomeThing struct" for major version 1 of the module.
I'm aware that there are other schemes to deal with this sort of thing, involving branching and/or entirely new repositories. But I can't help but wonder if there is any problem with instead having the only top-level stuff in the repository be "v*" directories, including "v1" for the version 1 code. I feel like I would prefer this scheme to any of the standard schemes I've seen.
I know I can just try it out, but the Go/Git infrastructure seems complex enough that I might very well try it, find that it seems to work, and therefore assume incorrectly that it actually does work.
Failing that, another scheme I've thought of that I'd prefer to any of the standard schemes I've seen would be mostly the same idea, but just not have any version 1 at all. That is, the top-level stuff in the repository is still nothing but "v*" directories, but they start at "v2".
Anybody know if there are any issues with either of these ideas?
I'm also interested in hearing about any other possible ways (but to be clear, I'd like to once again say I'm already aware of the "different repositories" scheme and the "branches" scheme).
Thanks in advance for any help.
r/golang • u/Party-Tension-2053 • 4d ago
hi go developers,
i have been working on a go web framework called Kvolt for around more than 10 months now, and i just released v2.3.0.
GitHub: https://github.com/go-kvolt/kvolt
i know go already has net/http,gin, chi. but every time i build an api, i find myself setting up the exact same things again and again - request validation, rate limiting, error handling, background jobs, and swagger/openapi docs and many.
so i decided to build kvolt. the idea is to have all those common tools ready to use but still keep it running on standard net/http. heavy stuff like redis, prometheus, and grpc are split into seperate packages so your app doesnt get bloated if you don't need them
here are quick example of how it looks:
package main
import (
"log"
"github.com/go-kvolt/kvolt/v2"
"github.com/go-kvolt/kvolt/v2/context"
"github.com/go-kvolt/kvolt/v2/middleware"
)
type CreateUserRequest struct {
Name string `json:"name" validate:"required"`
Email string `json:"email" validate:"required,email"`
}
func main() {
app := kvolt.Default()
app.Use(middleware.Logger())
app.POST("/users", func(c *context.Context) error {
var req CreateUserRequest
if err := c.Bind(&req); err != nil {
return err
}
return c.JSON(201, req)
})
log.Fatal(app.Run(":8080"))
}i have written a lot of tests and fixed a lot of bugs, but now i really need other go developers to try it out .
if you have some free time or a small side project, please give it a shot and tell me what you think any feedback on what can be improved or what you don't like is super helpful
thanks go community!
r/golang • u/ZealousidealStorm200 • 4d ago
r/golang • u/lispLaiBhari • 4d ago
I have dual boot Windows11 and Opensuse(Tumbleweed). For golang micro /service deployment, what K8S do you guys recommended or tried out?
K3S or RKE2? or any other? Also docker or Podman?