How to Build a Pluggable Library in Go

While exploring Envoy Proxy, I got intrigued by how users can write custom code as plugins and load those implementations at runtime. This curiosity led me down a rabbit hole of research, where I stumbled upon the buildmode=plugin option in Go’s official documentation. The documentation was pretty straightforward, so I decided to try it out, and now I want to share what I’ve learned. What is go buildmode=plugin? The go buildmode=plugin option allows you to compile Go code into a shared object file....

August 22, 2024 · 12 min · 2519 words · Jose Sitanggang

Graceful Shutdown in Go

Imagine you have a production service running on Kubernetes that is currently processing client requests while also deploying a new version to production. What will happen to those requests? Will those requests be lost, or will your service wait until all requests have been completed before upgrading? Let’s watch the demo below to provide a better context for the problem we are trying to solve. In the first part, the server is not implementing graceful shutdown....

November 2, 2023 · 7 min · 1486 words · Jose Sitanggang

Namespace in Go

Actually, Go doesn’t have a namespace feature like C++ and C# does. However, we can achieve the same effect in Go. How? Let’s examine the problem for a moment to ensure that we are on the same page. I have a package called httpkit. This package contains many helpers for developing REST APIs. package httpkit // MuxOption is an option for customizing the ServeMux. type MuxOption func(mux *ServeMux) // NewServeMux creates a new ServeMux with given options....

October 29, 2023 · 6 min · 1239 words · Jose Sitanggang