Blog

RSS

Generating Go code with Llama2 on your laptop

I would like to briefly show you how to generate Go code with Code Llama (the code version of Llama 2) locally on your laptop. We'll be doing that using the excellent llm CLI tool by Simon Willison.

Read the rest of “Generating Go code with Llama2 on your laptop”.

ChatGPT4 for data analysis

LLMs are mind-blowingly good at analyzing and visualizing data!

Read the rest of “ChatGPT4 for data analysis”.

Speeding up Postgres integration tests in Go

I've found a really nice way to speed up Postgres database integration tests considerably. It gave me a 3x speedup. Before, I ran database migrations setup and teardown before and after every integration test, using a migrate tool and a long-running Docker database container.

The solution involves using the Postgres template database functionality. The code examples in this post are going to be in Go, but this method applies to any other language where you're using integration tests with Postgres.

Read the rest of “Speeding up Postgres integration tests in Go”.

Building view components with gomponents and TailwindCSS in Go

TailwindCSS has taken the CSS framework world by storm. Its inline, utility-first approach to styling with CSS classes makes it perfect for using together with a component library like gomponents, to make it easy to build your server-side-rendered web apps in Go. In this post, I'll show you how.

Read the rest of “Building view components with gomponents and TailwindCSS in Go”.

Using dot imports in views in Go

I listened to an episode of the GoTimeFM podcast recently, about what the panelists would remove from the Go language, if it were possible if not for the Go version 1 backwards compatibility guarantee.

Ironically, this got me thinking about a nice use case for dot imports: when using the gomponents view library I'm building.

Read the rest of “Using dot imports in views in Go”.

Creating a Docker image for a Go application

The Go compiler produces a nice, single binary that's easy to deploy already. However, sometimes it's convenient to containerize your application. In this blog post, I'll show you a Dockerfile you can use as a template, and give you the reasoning behind each line in it.

Read the rest of “Creating a Docker image for a Go application”.

Structuring and testing HTTP handlers in Go

There are many ways to structure your HTTP handlers in your web application code in Go. It would be nice to have a default way to do this. After quite a few different designs, I've found a way I like, and in this post, I'll show you.

Read the rest of “Structuring and testing HTTP handlers in Go”.

gomponents: declarative view components in Go

I miss building views like in the React/Javascript world when in Go-land.

There's something so natural about thinking your view in terms of being built out of components. Everything from the buttons you use everywhere, to the big, interactive pages that pull everything together, it just feels easy to build pages from these building blocks.

Read the rest of “gomponents: declarative view components in Go”.

Authentication for REST APIs in Go

There are many options and opinions on how to add authentication and authorization to an HTTP REST API in Go. I was looking for something to let me provide simple username and password-based authentication in my web projects, no third-parties involved. In this post, I will provide the solution that I found to be the simplest, most battle-tested of all.

Read the rest of “Authentication for REST APIs in Go”.

Introductions

Hi, I'm Markus. 😊 I'm a professional software developer specialising in backend web services and distributed systems, but I also like building web products, full-stack style. I've been building web sites and programming since my early teens.

Read the rest of “Introductions”.

About me

I’m Markus, a professional software consultant and developer. 🤓✨ You can reach me at [email protected].

I'm currently building Go courses over at golang.dk.