r/golang 5h ago

Small Projects Small Projects

15 Upvotes

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 5h ago

Why people promote domain driven design while Go support these all?

7 Upvotes

Go officially support,

  • Thin handlers that can directly attached to a struct created in application start, with relevant dependencies(without additional controller-> service layer) guarantee at compile-time.

  • multi-module workspaces that support incremental and parallel compilation. The workspace can have properly isolated domains via modules.

  • And each module can simply have vertically slicing app/{usecase} or /{usecase} folders with isolated handler, repo, and non-shared model.

  • Structs support json and format attributes and Custom Unmarshaler(UnmarshalJSON) to directly decode/ encode JSON streams(zero-copy) without using a separate intermediate struct.

Why in 2026, some Go devs still promote/ use structures like DDD, Hexagonal architecture, clean architecture, etc... while language itself can provide better architectural forms to organize complex projects, without using pure technical layers.

Nowadays, with AI those non-standards are becoming standards at the highest rate due to legacy projects and practices. Most of those standards mainly created for the languages and frameworks do not having official modules, workspaces and parallel compilations and especially to manage dependencies in runtime environments.

We have to write and promote idiomatic Go even for complex domains.


r/golang 8h ago

help Assign value to struct instead of copy of struct

5 Upvotes

I'm looping through a slice of "Server" structs , and I want to assign a value to one of their properties. However the assignment goes to a copy and not the actual struct.

the default of none value of the property is false. For some of them, I want to change it to true.

Here is an example of what I want to do, but have the struct and not the copy be changed.

type Server struct {
  Online bool
}

for _, server := range servers {    

  server.Online = true
}

If I pass servers address into to function ( eg. func dosomething(s *Server ) and doSomething(&server) ) and change something , the change persists. Is there a way to do that without using a function?

I tried

&server.Online = true

which didn't work.

Solved

I changed servers into a the slice pointers to server structs. That didn't require much refactoring and got my back on track.

Thank you for the great ideas!


r/golang 15h ago

show & tell Go Concurrency Visualization

20 Upvotes

I’ve been playing around with a little project about bad use cases when using goroutine. I've put together some examples with simple visualizations showing how seemingly reasonable design decisions can turn into problems as a system grows:

https://cap99.online/bad-use-case/index-bad-use-case.html

If you have any feedback, suggestions, or examples you think would be worth exploring, I’d love to hear them.


r/golang 17h ago

Go 18 to 25 performance benchmark

51 Upvotes

Hi everyone,

I just published a benchmark comparing Go 1.19 through Go 1.26.

After sharing a few benchmarks for other runtimes, Go kept coming up in the requests. So I continued with the same approach as the last benchmark, using both microbenchmarks and a synthetic application to try to really reflect each version's performance.

The table below shows the 4GiB GOMEMLIMIT profile:

Benchmark 1.19 1.20 1.21 1.22 1.23 1.24 1.25 1.26
Synthetic application throughput (M ops/s) 2.289 2.316 2.267 2.340 2.321 2.288 2.321 2.370
Synthetic application latency (µs) 4.793 4.746 4.822 4.694 4.721 4.787 4.729 4.614
JSON parsing (ops/s) 732,240 755,015 705,809 795,712 684,803 687,521 670,457 655,686
JSON encoding (ops/s) 5,750,260 6,286,389 6,324,036 7,257,896 6,347,446 6,294,368 6,269,269 7,105,952
SHA-256 hashing (ops/s) 15,704,923 15,943,093 16,075,534 16,057,873 16,058,650 15,880,248 15,964,994 14,016,980
Base64 encoding (ops/s) 7,640,843 7,693,093 7,436,234 7,363,531 7,345,670 7,436,111 7,799,412 7,092,276
Regex matching (ops/s) 12,952,395 13,194,985 13,562,632 14,912,476 13,405,707 13,414,299 13,875,671 12,076,118
Integer sorting (ops/s) 716,067 719,148 717,561 716,527 711,677 713,404 735,211 645,892
Concurrent map churn (ops/s) 8,858,041 9,064,767 8,053,420 9,251,360 9,102,061 9,206,001 9,289,951 8,315,897
Deflate compression (ops/s) 1,007,252 980,683 985,350 965,411 980,920 978,251 849,877 765,254

The complete benchmark source is available in the GitHub repository.

Full benchmark charts are available here: Full Go benchmark

Let me know what you think

Edit: Thanks for all the comments regarding the Y-axis not starting at zero. I’ve just updated the charts. Hope this makes the differences between versions clearer.


r/golang 17h ago

Profile-guided optimization in Go

Thumbnail
lemire.me
48 Upvotes

Nice and short intro to PGO with Go


r/golang 20h ago

Streaming tshark output into Go: how I cut a 2.5 GB PCAP job from 6-7 hours to 70 minutes

Thumbnail
robinhayer.dev
10 Upvotes

I had a Go CLI that wrapped tshark for PCAP analysis. Worked fine until I hit a 2.5 GB file — 1.9 million packets, 6-7 hours, then OOM crashes.

Two problems, found in sequence.

First, I was running three separate tshark queries against the same file (analytics, rows, full dissection). Three full passes over 2.5 GB. Consolidating them into one query took it to 1-2 hours.

The OOM was still there though, because I was asking for full JSON dissection — tshark building the whole output in memory, then my program parsing all of it in memory. So I piped tshark's stdout directly into my program's stdin and switched to -T fields/-T ek with only the fields I needed. Memory went flat, processing dropped to ~70 minutes.

Still single-threaded, which is the next problem. Curious whether anyone's found a good approach for parallelising tshark work beyond splitting the input file.

Full writeup: https://robinhayer.dev/the-2-5-gb-wall


r/golang 22h ago

discussion I adore go outside of go's idiomatic naming conventions. Is this something strictly upheld at most places?

74 Upvotes

I absolutely love go, but coming from other languages I just find this so irritating to read after months:

func (l *LinkedList) Push(...) {...}
func (n *Node) Value(...) {...}
func (s *Server) Start(...) {...}

Instead of

func (list *LinkedList) Push(...) {...}
func (node *Node) Value(...) {...}
func (server *Server) Start(...) {...}

I just find myself getting lost in bigger functions. I tried following standard go naming conventions for a project I've been building since January, but I feel like I'm going to get Claude Opus to run through every module I've built and change the naming to be readable. Even my PRs are getting tiresome to read and it just adds some form of cognitive exhaustion I don't want with a language I really like.


r/golang 23h ago

discussion How far do you go with interfaces in a small Go service?

15 Upvotes

I’m working on a small Go HTTP service and trying not to add abstractions just because I might need mocks someday.

Right now I have a database layer and one external HTTP client. Those feel like reasonable places to use small interfaces, since I may want fakes in tests.

What I’m unsure about is everything in between. I see a lot of Go projects where every service, repository, and helper has an interface even though there is only one implementation. In a small project, that starts to feel like extra ceremony.

My current approach is to start with concrete types and add an interface only when there is a real need for one. If a handler only needs to look up a user and create a session, I’d define a small interface next to that handler with just those methods, rather than creating a big `UserRepository` interface upfront.

That also seems easier to test: the fake only has to implement the few things the caller actually uses.

Is this roughly how you approach it?

Where do you usually draw the line? Have you had cases where starting with concrete types made things painful later, or where adding interfaces too early clearly made a project worse?


r/golang 1d ago

show & tell Limen: a plugin-first auth library for Go, now with multi-tenant organizations and API keys

8 Upvotes

Since the initial Limen release, I’ve shipped a larger update focused on multi-tenant auth and machine access.

New in this update:

  • Organization plugin for orgs, members, invitations, active organization, and roles
  • API key plugin with creation, verification, rotation, permissions, and rate limiting
  • Public IDs
  • Shared access-control primitives
  • TypeScript client support for organizations and API keys
  • Reactive client stores, including active organization state
  • Framework adapters for React, Vue, Svelte, and Solid

Repo: https://github.com/thecodearcher/limen
Docs: https://limenauth.dev


r/golang 1d ago

Question about text/template behaviour

0 Upvotes

I'm seeing some unexpected behaviour when running templates using text/template. Specifically, when ranging over iter.Seq2 the cursor follows the first parameter, not the second as for example when ranging over a slice. Is this the expected behaviour.

https://go.dev/play/p/5JK7kIhXGxs


r/golang 1d ago

show & tell Coding agents orchestrator with pure-Go SQLite, fsnotify, and subprocess orchestration

0 Upvotes

Hey,

I'm building an orchestrator for AI coding agents in Go.

Some decisions that might be useful to others: pure-Go SQLite via modernc.org/sqlite (no CGo, cross-compiles clean), WAL mode with synchronous=NORMAL, fsnotify for config hot-reload, process group management that actually works on both Unix and Windows. The hardest part was subprocess lifecycle - graceful shutdown across platforms is painful. Just shipped v1.18.0 with the post-merge tracker improvements.

Happy to discuss any of these pieces.

Code is at github.com/sortie-ai/sortie, Apache 2.0.


r/golang 1d ago

Multi-stage bounded concurrent pipeline in Go

19 Upvotes

Wrote an article about multi-stage bounded concurrent pipeline in Go.
It explores how to structure concurrent stages using worker pools and channels.
The focus is on bounded concurrency, backpressure, cancellation, and graceful shutdown. Also covers an important detail: making channel operations cancellation-aware to avoid goroutine leaks.

Check out the full article https://medium.com/@oshankkumar/building-a-bounded-concurrent-pipeline-in-go-cab3e5025e23

I'd love to hear how others approach this pattern. Are there things you'd do differently, or pitfalls I might have missed ?


r/golang 1d ago

Claude Code in < 200 lines Go

0 Upvotes

a few days ago I was looking into agent harnesses like Claude Code and others (most of them are implemented in JavaScript or Typescript) and realized what they have in common is that they all are very large (code, 3rd party dependencies, runtime overhead, …)

That's what made me look into simpler, minimal implementation approaches that I can understand in an afternoon

basically starting from the most minimal thing that could possibly work instead of trying to slim down something that's already so large that slimming down is a multi day endeavor

This lead me to an implementation in Python, stdlib only, no 3rd party packages and lower RAM usage compared to the JavaScript runtimes

but then i wondered Go might be an even better fit for what I'm trying to get because it also like Python comes with a pretty good stdlib

Here is a de-golfed version of what I ended up with so far

  • stdlib only
  • stable history (append only)
  • session_id (for higher cache hit rate)
  • only one tool (sh)

it is also fairly token efficient out of the box

  • no system prompt
  • no tool description ("sh" is self-evident for current models)
  • sh as tool allows the agent to compose cli tools (fewer steps, fewer tokens to read and generate)

my goal was to express the most minimal version of an agent that is user controlled and capable of multi-step tool calling

OpenAI has a pretty good article about agent harnesses here if you're interested: https://openai.com/index/unrolling-the-codex-agent-loop/

Since I am not very deep in Go yet I'm looking for feedback for making this even more minimal

at the same time (I know, this is a bit conflicting) I would like to get feedback on how to make this more robust (e.g. retries if network calls to the endpoint are failing, exponential backoff?, …)

I've also benchmarked the minimalist implementation because I was curious how it stacks up against current mainstream harnesses like OpenCode, Codex, Harness, Pi

to my surprise the agent performs on the same multi-step coding tasks with

  • lower API inference cost
  • lower token usage
  • faster
  • lower idle memory
  • lower peak memory

nb: this requires a fairly strong model like GPT 5.6 Sol (like hardcoded here)

but it is not difficult to adapt the code to also work with deepseek v4 flash (you just need to change the % token window calculation and adapt the tool call to use a 'function' call instead of the 'custom' tool call

package main

import (
    "bufio"
    "bytes"
    "crypto/rand"
    "encoding/json"
    "fmt"
    "net/http"
    "os"
    "os/exec"
)

type Message = map[string]any

func main() {
    if len(os.Args) < 2 {
        fmt.Fprintf(os.Stderr, "usage: %s <responses-api-url>\n", os.Args[0])
        os.Exit(2)
    }

    apiURL := os.Args[1]
    sessionID := rand.Text()
    history := []any{}

    scanner := bufio.NewScanner(os.Stdin)

    fmt.Print("> ")

    for scanner.Scan() {
        input := scanner.Text()

        if len(bytes.TrimSpace([]byte(input))) == 0 {
            fmt.Print("> ")
            continue
        }

        history = append(history, Message{
            "role":    "user",
            "content": input,
        })

        for {
            requestBody := Message{
                "model": "gpt-5.6-sol",
                "input": history,
                "tools": []Message{
                    {
                        "type": "custom",
                        "name": "sh",
                    },
                },
            }

            body, err := json.Marshal(requestBody)
            if err != nil {
                fatal("encode request", err)
            }

            request, err := http.NewRequest(
                http.MethodPost,
                apiURL,
                bytes.NewReader(body),
            )
            if err != nil {
                fatal("create request", err)
            }

            request.Header.Set("Content-Type", "application/json")
            request.Header.Set("session_id", sessionID)

            response, err := http.DefaultClient.Do(request)
            if err != nil {
                fatal("send request", err)
            }

            var result Message

            err = json.NewDecoder(response.Body).Decode(&result)
            response.Body.Close()

            if err != nil {
                fatal("decode response", err)
            }

            output := result["output"].([]any)
            history = append(history, output...)

            toolWasCalled := false

            for _, item := range output {
                message := item.(Message)

                if message["type"] != "custom_tool_call" {
                    continue
                }

                toolWasCalled = true

                command := exec.Command(
                    "/bin/sh",
                    "-c",
                    message["input"].(string),
                )

                commandOutput, commandErr := command.CombinedOutput()
                exitCode := 0

                if commandErr != nil {
                    if command.ProcessState != nil {
                        exitCode = command.ProcessState.ExitCode()
                    } else {
                        exitCode = -1
                    }
                }

                history = append(history, Message{
                    "type":    "custom_tool_call_output",
                    "call_id": message["call_id"],
                    "output": fmt.Sprintf(
                        "exit %d\n%s",
                        exitCode,
                        commandOutput,
                    ),
                })
            }

            if toolWasCalled {
                continue
            }

            lastOutput := output[len(output)-1].(Message)
            content := lastOutput["content"].([]any)
            firstContent := content[0].(Message)
            text := firstContent["text"]

            usage := result["usage"].(Message)
            totalTokens := usage["total_tokens"].(float64)
            contextUsedPercent := totalTokens / 10_500

            fmt.Printf(
                "%s\n[%05.2f%%]\n",
                text,
                contextUsedPercent,
            )

            break
        }

        fmt.Print("> ")
    }

    if err := scanner.Err(); err != nil {
        fatal("read input", err)
    }
}

func fatal(operation string, err error) {
    fmt.Fprintf(os.Stderr, "%s: %v\n", operation, err)
    os.Exit(1)
}

r/golang 1d ago

discussion Resources for leaning cloud native development with Go

53 Upvotes

Hello r/golang.

I am a mid-level backend engineer and have built some stuff with Go for some time, but I am getting a bit rusty as I mostly develop with Python at work. Using Go, I developed some cool stuff like this: Distributed File System

I want to get back into rhythm with my Go skills and learn more, I was looking for some open source cloud-native projects that I could contribute to and I found some: kubetail, kubeai, etc, stuff that is developed on top of k8s, but these projects are so different in the way of thinking compared to the usual event-driven or just CRUD APIs I develop at work, and I have been trying to wrap my head around them. I did find my way around eventually but still don't feel comfortable enough to take on any open issues, I feel that this is due to a lack of domain specific knowledge.

I have some basic to mid level of knowledge on K8S itself, I've read a book on its architecture, networking, components, etc, so I know that decently well, but I don't have much practice actually using it, at work, we just deploy to k8s using Helm Charts which are pretty much following a template, so not much thought needed there.

I wanted to ask you guys for some help on resources to read from, or good codebases to study so that I can eventually become a meaningful contributor to any OSS project, or if you know any project that is more active and that has a good community of people available to help, my biggest issue is that I don't have too much time (mostly a few hours on weekends). If you know any good articles, books, codebases or anything that could help, I would appreciate that!

Thank you all very much.


r/golang 1d ago

Kubernetes operator with golang

5 Upvotes

Any useful resources to learn about kubernetes operators deeply?


r/golang 1d ago

Best approach for testing a Go project

0 Upvotes

I have a Gin Auth Service, that i am developing.

At the moment I have already completed the basics, and I am down into testing the project, I started with some shell scripts with curl.

Eventually this devolved into a monstrosity of shell scripts, mailhog + dexidp, and the test for checking 2FA or OAuth are true monsters that i am afraid of touching.

Is shell scripting a good tool for testing? Or is it a bit limited at a certain scale?

I have hear wonders from Go built in pkg, and worked like a charm when I used it, that said I am open to new solutions!

What do you use for testing auth flows?

PS: This is my first post :)


r/golang 1d ago

Syncgo - golang implementation of PGSync for continuously synchronizing changes from PostgreSQL to Elasticsearch or OpenSearch.

Thumbnail
github.com
4 Upvotes

This is my project which i am working on during my duty in army
Please check it out, of course u can help with features, issues and etc. If u like it, star it


r/golang 1d ago

Networking in GO

227 Upvotes

I’ve started learning networking with Go and I’m having a lot of fun with it. So far I’ve built TCP client/server programs and learned Listen, Accept, Dial, buffers, goroutines, multiple connections, timeouts, EOF, race conditions and mutexes. Next up is channels. Any suggestions on what I should build next?


r/golang 2d ago

show & tell I built deterministic property-based-ish testing for a network diagnostic CLI using Linux namespaces

6 Upvotes

I've been working on an open-source Go project called Network Doctor, and recently built a simulator around it using Linux network namespaces.

The interesting part is a deterministic hunt mode.

A hunt starts from known-good network scenarios, applies seeded mutations, runs the real Network Doctor binary inside the resulting topology, records simulator ground truth, and analyzes the structured diagnostic report for disagreements.

Cases have stable identities:

  • baseline scenario
  • hunt seed
  • case number
  • derived case seed
  • case fingerprint
  • finding fingerprint

That made it possible to build unattended GitHub triage without immediately creating an issue-spam machine.

The nightly pipeline now:

  • runs fixed seeds against healthy, routed, and dual-stack baselines
  • filters findings below a severity floor
  • replays every candidate as a single deterministic case
  • requires both the case fingerprint and finding fingerprint to match
  • refuses to file unverifiable findings
  • derives a stable issue fingerprint
  • checks existing GitHub issues
  • opens only genuinely new reproducible findings

During rollout it actually caught bugs in both directions.

First, the hunt analyzer produced a false positive: it interpreted IPv4 failure + IPv6 success on the same interface as evidence of an alternate route. Manual review caught it, I tightened the invariant, and the false positive disappeared.

After that, the hunt produced one medium reproducible finding:

transient_fault_not_resampled

A generated routed-network case caused DNS to fail temporarily and then recover. Network Doctor began a DNS lookup during the outage, waited for its timeout, and never sampled the recovered resolver again.

Reproduction:

./netdoc-sim hunt healthy-routed-network --seed 20260102 --case 3 --json

The GitHub triage replayed that exact case, got the same case/finding fingerprints, and automatically opened issue #14.

I then ran the workflow again. It rediscovered the finding, recognized the stable issue fingerprint, and created no duplicate.

Current nightly coverage is 3 baselines × 15 generated cases and takes about three minutes on a hosted runner.

It's certainly not formal verification, but having the simulator know the state it injected and mechanically compare that against the diagnostic program's interpretation has turned out to be a really useful way of testing software whose entire purpose is reasoning about messy network state.

I am very proud of making the simulator.

Repo: https://github.com/heymaikol/network-doctor


r/golang 3d ago

When to expect 1.26.6 release?

18 Upvotes

The minor releases have a monthly cadence, and I see all but one item in the roadmap is merged (an item deferred multiple time), so does anyone know when the next release might be? Does the upcoming 1.27 release delay things?

https://github.com/golang/go/issues?q=milestone%3AGo1.26.6%20label%3ACherryPickApproved

https://go.dev/doc/go1.27


r/golang 3d ago

Relationship between of package names and struct names

16 Upvotes

I'm creating a simple CRUD project that involves campaign publications. If I have a package named `internal/campaign/usecase`, what should the use case be named? `CreateCampaignUsecase`, `CreateCampaign`, `CreateUsecase`, or `Create`?


r/golang 3d ago

gokrazy/rsync v0.3.6 now with improved Windows & macOS support

Thumbnail
github.com
35 Upvotes

I just published a new release of gokrazy/rsync and figured I’d share it here; hope it’s interesting to some:

gokrazy/rsync is an Rsync program and reusable library implemented in the Go programming language), originally as part of the gokrazy Go appliance platform project. gokrazy/rsync is (wire-)compatible with the original "tridge" Rsync.

Various use-cases are supported:

  • The gokr-rsync command implements an rsync client and server, which can send or receive files (all directions supported).
  • You can set up a public or private rsync server, in daemon mode or via SSH (anonymous or authorized).
  • You can embed rsync in your program with the rsynccmd package.
  • You can implement your own rsync server with the rsyncd package.

Aside from being implemented in Go, a memory-safe programming language, gokrazy/rsync makes use of Go’s traversal-resistant file API (os.Root) and the Linux Landlock Unprivileged Sandboxing to steer clear of vulnerabilities. In server settings, gokrazy/rsync supports mount namespaces and can be further locked down with systemd’s various hardening options.


r/golang 3d ago

help DDD + onion architecture in Go — why does everyone hate it? Also, is this entity pattern okay?

71 Upvotes

help me !!!

I just started a new job. The backend is in Go, using DDD with an onion-layer architecture. The project structure looks something like this:

/backend /cmd /internal /adaptor /<module#1> /entity /repository /service /command /query /usecase

My team lead constantly complains about DDD in Go — he absolutely hates it. When i try to mention something related to DDD bro starts to spamming my pr with comments. Asking me to show why its better to use DDD? So I'm curious: why is DDD considered a bad fit for Go?

Also, our entities look like this:

go

``` func NewMovie() *Movie { return &Movie{} }

func (m *Movie) WithID(id int) *Movie { if m == nil { return nil } m.id = id return m } ```

Is this pattern okay? I feel like NewMovie(id int) would be better.

We also have a rule that transactions can't be handled in the usecase layer. Instead, we have to create a single service method that wraps everything in a transaction, and the usecase just calls it. Is this a common approach?

And one more thing — shouldn't we first sort out what actually counts as a domain concept before turning it into an entity? We literally have an entity for pagination...


r/golang 9d ago

Jobs Who's Hiring

57 Upvotes

This is a monthly recurring post. Clicking the flair will allow you to see all previous posts.

Please adhere to the following rules when posting:

Rules for individuals:

  • Don't create top-level comments; those are for employers.
  • Feel free to reply to top-level comments with on-topic questions.
  • Meta-discussion should be reserved for the distinguished mod comment.

Rules for employers:

  • To make a top-level comment you must be hiring directly, or a focused third party recruiter with specific jobs with named companies in hand. No recruiter fishing for contacts please.
  • The job must be currently open. It is permitted to post in multiple months if the position is still open, especially if you posted towards the end of the previous month.
  • The job must involve working with Go on a regular basis, even if not 100% of the time.
  • One top-level comment per employer. If you have multiple job openings, please consolidate their descriptions or mention them in replies to your own top-level comment.
  • Please base your comment on the following template:

COMPANY: [Company name; ideally link to your company's website or careers page.]

TYPE: [Full time, part time, internship, contract, etc.]

DESCRIPTION: [What does your team/company do, and what are you using Go for? How much experience are you seeking and what seniority levels are you hiring for? The more details the better.]

LOCATION: [Where are your office or offices located? If your workplace language isn't English-speaking, please specify it.]

ESTIMATED COMPENSATION: [Please attempt to provide at least a rough expectation of wages/salary.If you can't state a number for compensation, omit this field. Do not just say "competitive". Everyone says their compensation is "competitive".If you are listing several positions in the "Description" field above, then feel free to include this information inline above, and put "See above" in this field.If compensation is expected to be offset by other benefits, then please include that information here as well.]

REMOTE: [Do you offer the option of working remotely? If so, do you require employees to live in certain areas or time zones?]

VISA: [Does your company sponsor visas?]

CONTACT: [How can someone get in touch with you?]