Solana dApp Architecture

Backend Architecture Data Flow The backend provides data to the frontend via an API, with its primary responsibility being indexing blockchain data, such as transactions. To achieve this, the indexer continuously queries the Solana blockchain and stores the relevant data for efficient retrieval. Why Indexing? The Need for Indexing Raw blockchain data is not optimized for fast queries. Without indexing, fetching relevant information directly from the blockchain is inefficient because: ...

March 28, 2025

Pluralization Example in Go

func main() { text, err := getPluralItemText(1) if err != nil { log.Println(err) } fmt.Println(text) text, err = getPluralItemText(10) if err != nil { log.Println(err) } fmt.Println(text) } func getPluralItemText(count int) (string, error) { msg := plural.Selectf(1, "%d", plural.One, "%[1]d item", plural.Other, "%[1]d items") key := "%d item" tag := "en" lTag := language.MustParse(tag) err := message.Set(lTag, key, msg) if err != nil { return "", err } p := message.NewPrinter(language.English) s := p.Sprintf("%d item", count) return s, nil } Result 1 item 10 items

April 30, 2024

Common Anti-Patterns in Go Web Applications

Loose Coupling Anti-pattern: The Distributed Monolith Avoid splitting your application into microservices before you understand the boundaries. Tactic: Deploy loosely coupled modules. DRY introduces coupling Anti-pattern: Over-Coupling Through “Don’t Repeat Yourself” Adhering strictly to DRY can lead to strong coupling. Tactic: Being DRY in Go A Single Model Couples Your Application Anti-pattern: The Single Model In web applications, the views your API returns (read models) are not the same thing you store in the database (write models). ...

October 30, 2023

Message Ordering Problem in Pub/Sub

Tips for formatting time in Go

August 15, 2023

Formatting Time in Go

Tips for formatting time in Go

March 7, 2023