RSS Amplifier

kubuzetto's blog · Jun 1, 2025

Automatic Go Union Deserialization Dispatch with Tags

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

Introduction Ok, this will be a short one. In the previous posts ; we tried to reduce endpoint handler boilerplate in Go by imitating the Axum magic functions. This post is not about that, but I think one of the tricks we pulled there may have another use case. If you’ll recall, we iterated through two separate solutions to the endpoint problem, where in the latter one we used struct fields…

Introduction

Ok, this will be a short one.

In the previous posts; we tried to reduce endpoint handler boilerplate in Go by imitating the Axum magic functions. This post is not about that, but I think one of the tricks we pulled there may have another use case.

If you’ll recall, we iterated through two separate solutions to the endpoint problem, where in the latter one we used struct fields to represent endpoint parameters. To initialize those fields into any references that internally retain type info, we used reflect.NewAt with the field offset like this:

Read on /posts/go-deser-dispatch/

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.