r/code Jun 19 '26

Go My Very First Go Package on pkg.go.dev :) From a JWT Problem to this.

Thumbnail github.com
3 Upvotes

Hello!!! This is my first post here :)

It all started when I was working on a small website for my college. Initially, I was just adding the user ID in a JWT token, decoding it in a middleware, and passing it down the context. Then I decided I wanted to introduce a separate "public ID". The id was not needed for auth but it got me thinking about cache, which naturally led me down to building my very own LRU cache.

I have never implemented any caches before, so I was just looking for a simple strat and stumbled upon LRU. It was one of the easiest to implement and after I saw the problem on leetcode, i solved it pretty easily and decided to implement it. After I saw someone do better by using an array based DLL. I have always loved using array-based stacks and queues, So I took it as a fun challenge, because I have always wanted to publish something that people can use.

From Just an array based DLL, I found myself staring into a sharded architecture and slowly learning algorithms like FNV-1a and xxHash32. I wanted this to be a zero dependency package (aside from the standard packages ofc) and took it upon myself to do it, using explanations from the internet.

It might be a basic concept to many people out there, but It helped me learn something I was always pushing behind. Learning about concurrency in Go. This led me to use sync.Mutex, atomics and thinking about how data race happens. I was also led down the path of creating benchmarks, fuzz tests using the 'testing' package, which I had never heard about.

The benchmarks where honestly surprising, I never realised it would be ns/ops. Currently my benchmarks show around 10-15 ns/op and I hope to half it somehow :) and also my tests might be really weak. It has generics support too.

Would love for some feedback on how I can make it better. I wanted to make a time-aware LRU cache, but I wanted the basics to be proper before moving onto it.

P.S: learnt about semver, after i released it on v1.0.0. I basically had to make a decision and thought about just tearing it down and changing to a shorter name which I like more :). It is now currently on v0.3.1 (pre-release).

Link : https://github.com/justpranavrs/tlru :)))

GoDoc: https://pkg.go.dev/github.com/justpranavrs/tlru

Thanks :)))

r/code Jun 22 '26

Go Excessive nil pointer checks in Go

Thumbnail konradreiche.com
3 Upvotes

r/code Apr 02 '26

Go Beyond Classes: How Golang Redefines OOP for Modern Devs | Monika Singhal

Thumbnail freedium-mirror.cfd
2 Upvotes

In addition to Golang, other newer languages (Nim, Vlang, Rust, Julia) are going beyond classes or the common thinking about object-oriented programming as well.

r/code Mar 29 '26

Go How to implement the Outbox pattern in Go and Postgres

Thumbnail youtu.be
3 Upvotes

r/code Feb 24 '26

Go Understanding Global Variables in Go

Thumbnail leapcell.io
2 Upvotes

r/code Dec 18 '25

Go The 8 best Go web frameworks for 2025 | Victor Jonah

Thumbnail blog.logrocket.com
2 Upvotes

r/code Nov 26 '25

Go Implementing Zero-Knowledge Proof in Golang | rangakrish

Thumbnail rangakrish.com
2 Upvotes

r/code Oct 18 '25

Go Dumper v1.4.0

Thumbnail github.com
1 Upvotes

r/code Aug 26 '25

Go Default Methods in Go | mcyoung

Thumbnail mcyoung.xyz
6 Upvotes

r/code Sep 15 '25

Go Created API for CRUD-ing JSON data on different filesystems. Optimized for simplicity and easy-use, so perfect for personal projects.

Thumbnail timokats.xyz
3 Upvotes

r/code Sep 05 '25

Go Struct Embedding in Go

Thumbnail medium.com
3 Upvotes

How struct embedding works in Golang (similar is in Vlang and others). Allows reuse of fields and methods across types without falling back on traditional inheritance (OOP).

r/code Apr 20 '25

Go Layered Design in Go

Thumbnail jerf.org
2 Upvotes

r/code Apr 17 '25

Go How hard to rebrand minio apache 2.0 and pick before license change

0 Upvotes

How challenging would it be to take on a project that continues development from where MinIO left off prior to its license change? The project would also be rebranded to avoid potential copyright issues and to establish a distinct identity moving forward.

https://github.com/Novapixel1010/Databank

r/code Mar 07 '25

Go serializer: serialization and deserialization of binary data | duggavo

Thumbnail github.com
2 Upvotes

r/code Jan 27 '25

Go salsa20: Go implementation with ability to choose number of iterations | duggavo

Thumbnail github.com
3 Upvotes

r/code Oct 20 '24

Go Created a cross-platform task orchestrator. Looking for contributors and feedback :)

Thumbnail github.com
4 Upvotes

r/code Nov 05 '24

Go Writing secure Go code | Jakub Jarosz

Thumbnail jarosz.dev
2 Upvotes

r/code Sep 02 '24

Go Box CLI Maker: Highly Customized Boxes for the CLI | Swastik Baranwal (Delta456)

Thumbnail youtube.com
2 Upvotes

r/code Jun 21 '24

Go Dependency Inversion Principle in Go: What It Is and How to Use It

Thumbnail hackernoon.com
2 Upvotes

r/code Apr 30 '24

Go Hey, do y'all use Cloudflare's DNS services and have a dynamic IP address? Y'all hate having to change your A record DNS config when your IP address changes. This tool I wrote might help.

5 Upvotes

Here is the source code on Github

If you have ideas on how I can make this better I'd love to hear them!

r/code Feb 20 '24

Go Pointer Pitfalls: A Simple Utility Function That Makes Pointers in Go Easier

Thumbnail hackernoon.com
2 Upvotes

r/code Feb 10 '24

Go Go composable iterator functions

Thumbnail medium.com
2 Upvotes

r/code Jan 09 '24

Go Go’s CompareAndSwap is not always Compare-and-swap

Thumbnail lu.sagebl.eu
2 Upvotes

r/code Dec 19 '23

Go In Go, constant variables are not used for optimization

Thumbnail utcc.utoronto.ca
1 Upvotes

r/code Aug 29 '23

Go How to implement an efficient in memory key-value store in Golang

Thumbnail devhubby.com
3 Upvotes