Skip to content

Go

PGX Error: Cannot scan unknown type

You probably end up here because you saw this error returned from jackc/pgx

cannot scan unknown type (OID 16458) in text format into *[]recipe.CategoryType

This error is connected with custom database types, so if this is what you did, this article is for you.

Echo middlewares

In this brief article, I aim to highlight an ideal use-case for middleware, shedding light on its functionality and practical implementation.

Middleware serves as a crucial intermediary between user requests and application logic. In the following example, I'll demonstrate how middleware can authenticate users and seamlessly pass custom context to a micro-service, streamlining the authentication process without burdening the service with additional authentication logic.

Golden File Testing in Go

In traditional unit testing, specifying expected outputs directly within the test function is common. However, when dealing with complex data structures, such as a large tree, this approach can become unwieldy. Enter golden file testing.

Golden file testing alleviates the burden of manually specifying expected outputs by storing them in separate files. Each test case has its own file containing the expected output, typically stored in a designated directory (commonly named "testdata" and placed adjacent to the test file).