RSSAmplifier

Blog

Posts

Recent content on Posts

jacoelho.comRSS feed ↗10 posts

Latest posts

Projects

Life in the UK - Quiz app covering questions for the British citizenship or indefinite leave to remain exam. Banking - Library to validate IBANs, with a page to check IBAN structure. XSD - Library go xsd validation library.

Dependency Lifecycle Management in Go

Introduction Lifecycle management ensures that application components like servers, databases, and background workers are correctly initialized, started in the right order, and gracefully stopped. Go developers typically wire dependencies manually, instead of relying on heavy frameworks or reflection based dependency injection. This approach improves readability and reduces hidden behavior, but it…

structured logging: slog

Event logging is one of the three pillars of observability (traces and metrics being the other two). A log entry is a timestamped record about the application’s activity, which can be used for troubleshooting, monitoring or auditing purposes. Logs may have different formats: unstructured or plain text: similar to print statements, free-form text semi-structured: some values have a structure…

Opentelemetry - Log-Based Change Data Capture tracing

Opentelemetry provides vendor neutral standards and implementations to generate, collect, and export tracing data. A Context is a propagation mechanism which carries execution-scoped values across API boundaries and between logically associated execution units. Cross-cutting concerns access their data in-process using the same shared Context object. Context propagation is required when the tracing…

Go Generic Programming - Testing the waters

Go Type Parameters Proposal is expected to be implemented with Go 1.18 early 2022. The Very high level overview section contains a nice overview of what to expect. If you have seen generics in other languages perhaps the most curious differences (other than using square brackets), are union types: type SignedIntegers interface { int | int8 | int16 | int32 | int64 } Similar in syntax to…

Go - On logging and dependencies

Doing code reviews, I have sometimes noticed libraries forcing dependencies on the users. While it is perfectly acceptable if well justified and documented, it sometimes feels like adding unnecessary baggage. A typical example would be something like the following snippet: func ( c * Client ) HealthCheck ( ctx context . Context ) error { logrus . Debug ( 'sending get request' ) req , err := http .…

PostgreSQL - UUID vs TEXT

In PostgreSQL one can represent UUID as UUID , TEXT or VARCHAR built-in types. Which type represents a UUID more efficiently? Mainly in the JSONB context? My gut feeling says built-in type UUID is way better. One trap with using TEXT is trying to compare different cases with equals: select 'ef9f94da-98ef-49fa-8224-32f3e1f592b3' = 'EF9F94DA-98EF-49FA-8224-32F3E1F592B3' as equal ; equal ------- f…

Go - Embed

Go 1.16 added a new embed package. While the idea is not a novelty, there were already some packages with slightly different APIs fulfilling similar roles, for example: go-bindata go-rice Having an official package is always a welcome addition to the batteries-included standard library. Usage A possible way to embed react assets could be as simple as: package web import ( 'embed' 'io/fs' )…

Go - On building URL strings

Building URL strings in Go may be accomplished in a couple different ways: url.Parse string concatenation (using + ) fmt.Sprintf bytes.Buffer strings.Builder You may be asking yourself: which one should I use, then? As always, the answer depends. Let us explore why. URL.Parse Before we start, a quick refresh on the URL structure: One important fact to be aware is that when building URLs manually,…

Writing a client library in Go

There are multiple ways of writing client libraries in Go. In this post, I will explore what I look for in a library depending if I am developing or checking if it is suitable for a project. Without any specific order of importance, these are my thoughts on the subject. Usage and Examples Like a book can be judged by its cover, a project can be judged by its README. Therefore providing examples…