r/golang • • 12h ago

What's coming in Go

Thumbnail
go.antonz.org
49 Upvotes

r/golang • • 2h ago

help Coming from Python: defer made my cleanup easier but I shot myself in the foot with it in a loop

12 Upvotes

After years of Python (I even taught a workshop on it at work), I finally got to write a real service in Go. I was processing files in a loop and used defer file.Close() inside the loop, then wondered why memory kept climbing on large batches — all those handles were staying open until the function returned, not each iteration. The fix was extracting the body into a helper function so defer fired per iteration, which is now obvious in hindsight. Lesson learned: defer is scoped to the function, not the block. Curious if others hit this their first month, or is it just me?


r/golang • • 6h ago

show & tell Go Interactive Practice: Classic challenges, package deep-dives, and Go release breakdowns (Open Source)

Thumbnail
github.com
8 Upvotes

r/golang • • 5h ago

Small Projects Small Projects

7 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 • • 9h ago

show & tell sgh: a Go CLI that fans GitHub operations out across every repo in an org

0 Upvotes

I've been building sgh, a CLI for org-wide GitHub operations: branches, tags, PRs, Actions runs and branch protection. The official gh works one repository at a time; this one takes an org and runs against all of its repos. I'm the author, and it's MIT licensed.

sgh branch create --org my-org --new Release-2.0 --ref main --dry-run
sgh workflow list --org my-org --failed --branch main
sgh protected-branch list --org my-org --branch main

The parts that might interest this sub:

  • A shared worker pool does the fan-out, with a configurable worker count.
  • Rate-limit tracking, exponential backoff and a circuit breaker sit around the GitHub API calls.
  • Tokens are stored per owner in the OS keyring, with a plaintext fallback and a warning when no keyring exists.
  • Output is table, compact or JSON, and there is a Bubble Tea TUI.
  • Test coverage is 93%, enforced in CI with an 85% floor.

Code: https://github.com/pradyb/sgh-cli

Docs: https://pkg.go.dev/github.com/pradyb/sgh-cli

I'd appreciate a review of the concurrency and error-handling design, and any criticism of the package layout.


r/golang • • 9h ago

show & tell API Gateway for AI Agents

0 Upvotes

I build API Gateway for AI Agents https://github.com/Clivern/Sloth. It is using A2A protocol. check it out and let me know what do you think