go

Fetching Advent of Code Inputs Dynamically in Go

Fetching Advent of Code Inputs Dynamically in Go

Advent of Code is a fun way for programmers to test and improve their problem-solving skills. While solving the puzzles, you might want to automate the fetching of your personalized puzzle input directly using its URL instead of copying the input to a text file that will be available locally. However, trying to access the input URL using a simple HTTP request, results in the message below: Puzzle inputs differ by user. Please log in to get your puzzle input. This article explains why this happens and how to correctly fetch your inputs dynamically using Go programming language. The Problem:…
Read More
Bridging CLI and Note-Taking

Bridging CLI and Note-Taking

As developers, we spend countless hours in the terminal. It's our primary interface for everything from git operations to server management. But what happens when you need to quickly jot down a thought or make a note while deep in a coding session? For me, this meant an annoying context switch. I use Logseq as my primary note-taking and knowledge management system, but every time I needed to make a quick note, I had to: Take my hands off the keyboard Reach for the mouse Switch windows to Logseq Navigate to today's journal Make my note Switch back to the…
Read More
Mastering ENUMs in Go

Mastering ENUMs in Go

Often, within the systems we develop, we encounter constant values. One example of these values could be the representation of a registration status. In this case, consider a status that includes more variations beyond active and inactive. If these statuses are defined as strings, their validation within the system could become a major headache. Additionally, this approach might “inflate” the binary, as each validation would involve two strings (the expected value and the value being validated). To avoid these problems, we can use the well-known enum type. If you’re unfamiliar with this type, it is essentially a fixed or limited-size…
Read More
From Theory to Practice: Developing a Distributed Key-Value Database with Sharding and Replication

From Theory to Practice: Developing a Distributed Key-Value Database with Sharding and Replication

Introduction Overview of Distributed Key-Value Databases Distributed key-value databases are a type of NoSQL database that store data as a collection of key-value pairs across a distributed system. Unlike traditional databases that rely on a centralized server, distributed key-value stores allow for horizontal scaling by spreading data across multiple nodes, which enhances availability and fault tolerance. This architecture is particularly suited for modern applications that require high throughput, low latency, and the ability to handle large volumes of data. In a distributed key-value database, each piece of data is identified by a unique key, making retrieval and storage efficient. This…
Read More
What is an interface in Golang, and why is it important in building large-scale systems?

What is an interface in Golang, and why is it important in building large-scale systems?

An interface in Golang is a set of method signatures (behaviors) without specifying how they are implemented. Any type that implements those methods is said to satisfy the interface, without explicitly declaring so. This feature allows for flexible, decoupled, and modular design. type Animal interface { Speak() string } type Dog struct {} func (d Dog) Speak() string { return "Woof" } type Cat struct {} func (c Cat) Speak() string { return "Meow" } func MakeAnimalSpeak(a Animal) { fmt.Println(a.Speak()) } func main() { dog := Dog{} cat := Cat{} MakeAnimalSpeak(dog) MakeAnimalSpeak(cat) } Enter fullscreen mode Exit fullscreen mode In…
Read More
Playing with Rust: Building a Safer rm and Having Fun Along the Way

Playing with Rust: Building a Safer rm and Having Fun Along the Way

Welcome to my YOLO series, where I'll be showcasing simple tools and projects that I've built—sometimes for fun, sometimes to solve specific problems, and other times just out of pure curiosity. The goal here isn't just to present a tool; I'll also dive into something interesting related to the process, whether it's a technical insight or a lesson learned while crafting these little experiments. Introducing rrm: The Command-Line Tool Nobody Asked For Nobody asked for it, and nobody want it—but here it is anyway. Meet rrm, a tool that solves a problem only I seem to have (but hey, it…
Read More
How to Consistently Retrieve Valid JSON from Claude 3.5 in Go

How to Consistently Retrieve Valid JSON from Claude 3.5 in Go

When working with LLMs as a developer, you often want to receive data in a structured format. While this didn't always work well in the early GPT-3 era, the current models that support function calling are much better at it. In this post, I want to share a simple function called CallClaudeForceTool, which you can use to call Claude to receive structured data/JSON output. In my case, it is written in Golang and returns any type of struct I need. First, you need to define the structure and provide it to the LLM in the format of a JSON schema.…
Read More
Autenticação, Autorização, MFA e muito mais com Golang

Autenticação, Autorização, MFA e muito mais com Golang

"Ó o cara falando de autenticação em pleno 2024!" Sim! Vamos explorar como realizar fluxos de autenticação e autorização, e de quebra, entender a diferença entre estar autenticado e estar autorizado (spoiler: não é a mesma coisa!). Neste texto, falaremos sobre três tópicos importantes: JWT (o queridinho do mundo stateless) OAuth (aquele que vive nas sombras das APIs de terceiros) Casdoor (uma ferramenta que promete facilitar sua vida) Autenticação vs. Autorização: Entendendo a Treta Se você já trabalhou com autenticação, provavelmente ouviu algo como: “Fulano foi autenticado, então ele pode acessar tal recurso”. Calma lá! Estar autenticado é apenas dizer:…
Read More
Doubly Linked List Implementation in Go

Doubly Linked List Implementation in Go

Hi there DEV.to community! As a second part of my previous post (linked in the series above), here we will implement a doubly linked list. A doubly linked list is just as a singly linked list with one difference. Each node refers to both its next node and its previous node. Thus we may move forward in the list using a function called GetNext and move to the previous node with a function called GetPrev. Image source: GeeksforGeeks Before we start here is the structure I'd like to organize my codes like: project ├── doubly_linked_list │ ├── node.go │ └──…
Read More
Learning GO: 05

Learning GO: 05

Hey! I am Currently learning Go Lang, and I am taking some basic Notes on my Notion and though I'd also just publish them here. They are not well thought out or well written but it's just me taking notes from time to time for my reference. I am taking the Udemy Course by Maximilian Schwarzmüller, Notes Defining Functions all the user defined Functions are defined below the main function a function in Go can be defined using func keyword We can add parameters to the function, when adding parameters we have to define the type of the parameter func…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.