Leinonen

Code, Mindfulness & Minimalism

Posts tagged with "go"

Found 3 posts.

Using SQLite with Go: Building a Flexible Database Abstraction Layer

By Peter Leinonen on August 1, 2025

Discover how to kickstart your new projects using SQLite with Go, and build a flexible database abstraction layer that allows you to seamlessly transition to any other database as your application scales. This blog post guides you through setting up SQLite for simplicity and speed, crafting an interface in Go for easy database swapping, and implementing it for different databases. Whether you're just starting or scaling up, ensure your application remains adaptable and robust.

Read more

Avoid global state in Go

By Peter Leinonen on July 27, 2025

Avoid the pitfalls of using global state in Go by embracing a cleaner, more maintainable approach with structs and dependency injection. Global variables often introduce hidden dependencies, leading to tight coupling, race conditions, and poor testability. By encapsulating dependencies in structs and passing them explicitly, you can enhance code clarity, testability, and safety. This method allows for easier testing and a more organized code structure, ensuring your Go projects are robust and scalable. Say goodbye to global state and hello to a more reliable coding practice.

Read more

Multiple build targets in Go

By Peter Leinonen on July 30, 2025

Discover how to maximize your Go projects with a single codebase for multiple build targets. By using a well-organized cmd/ directory, you can streamline development, reduce redundancy, and easily support various deployment environments. Keep your code DRY, scalable, and focused on innovation without repetition. Explore the power of Go and efficiently manage one codebase for diverse applications!

Read more