Generic dig for map key using typed parameters

Generic dig for map key using typed parameters Hello! I was fiddling with a way of getting out values from a map that is of format map[string]any. But I wanted my type safety as well. This was coming from digging out keys from a Metadata field. The metadata was in a JSON format. This is what I came up with: / FetchValueFromMetadata fetches a key from a metadata if it exists....

February 27, 2024 · 2 min · hannibal

CRD to YAML as WASM website

CRD to YAML as WASM website A while ago, I wrote about Generating Sample YAML files from CRDs. It’s a tool I created that lives here. It has a front-end service as well for convenience. I wrote it in a traditional client-server manner. It’s running from a Docker Swarm container. But, as I was thinking about it, nothing in this service requires interaction with a server. It gets some user input, processes it, and has some output....

December 1, 2023 · 5 min · hannibal

How to deploy a Go (Golang) backend with a React frontend separately on Kubernetes - Part One

Intro Welcome. This is a longer post about how to deploy a Go backend with a React frontend on Kubernetes as separate entities. Instead of the usual compiled together single binary Go application, we are going to separate the two. Why? Because usually a React frontend is just a “static” SPA app with very little requirements in terms of resources, while the Go backend does most of the leg work, requiring a lot more resources....

July 23, 2020 · 14 min · hannibal

How to do a good code review

Intro Hi folks. This time, I would like to talk a little bit about code reviews. How do you do code reviews? Don’t hesitate to share it in the comments. How do I do code reviews? Well read on if you would like to know. The Top Down approach If I’m dealing with a small code change, a couple of lines here and there in the odd file first, I’ll try to understand why the review is there?...

May 11, 2020 · 6 min · hannibal

How to Make SPA refresh work with a Go backend

Intro Hi folks. Today I would like to share a quick “fix” for a problem I’ve seen popping up here and there. That is, if you have a react frontend which is a SPA app but you still want refresh to work. What do I mean by that? Consider the following… The problem You have a SPA app with a react router which navigates the user around. The app calls to a backend api which serves content of some kind....

February 17, 2020 · 4 min · hannibal

Summary of Practical Go workshop from Dave Cheney

Intro Hi folks. So there is this workshop from Dave Cheney. And I thought I’d draw a sort of summary of that workshop. Right-click->Open Image for higher resolution. Cheers, Gergely.

October 10, 2019 · 1 min · hannibal

Efferent and Afferent metrics in Go

Intro Hi folks! Today I would like to write about a metric that I read in a book called Clean Architecture from Robert Cecil Martin ( Uncle Bob ). Abstract The metrics I mean are Efferent and Afferent coupling in packages. So you, dear reader, don’t have to navigate away from this page, here are the descriptions pasted in: Afferent couplings (Ca): The number of classes in other packages that depend upon classes within the package is an indicator of the package’s responsibility....

April 21, 2019 · 6 min · hannibal

Go SSH with Host Key Verification

Hi folks. Following a long search and reading lots of debates and possibilities of doing SSH within Go, I was shocked to see that not a great many tools and people use SSH with host key verification. What I usually see is this: HostKeyCallback: ssh.InsecureIgnoreHostKey() This is terrible. Now, I realise that doing HostKeyVerification can be tedious, but don’t fear. It’s actually easy now that the Go team provided the knownhosts subpackage in their crypto SSH package located here: KnownHosts....

February 17, 2019 · 2 min · hannibal

Extensive tutorial on go-plugin.

Intro If you don’t know what go-plugin is, don’t worry, here is a small introduction on the subject matter: Back in the old days when Go didn’t have the plugin package, HashiCorp was desperately looking for a way to use plugins. In the old days, Lua plus Go wasn’t really a thing yet, and to be honest, nobody wants to write Lua ( joking!). And thus Mitchell had this brilliant idea of using RPC over the local network to serve a local interface as something that could easily be implemented with any other language that supported RPC....

October 29, 2018 · 17 min · hannibal

Furnace with a new Plugin System

Hi. A quick update, but a very important and interesting one hopefully. Furnace just got a massive boost to its plugin system. I’m using HashiCorp’s Go-Plugins system now to handle plugins. This means one of two things that are interesting to the plugin author. One, plugins can be written in any language which is supported by Furnace and supports GRPC. Currently this means that plugins can be written in the following languages:...

September 17, 2018 · 1 min · hannibal