go

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
Singly Linked List Implementation in Go

Singly Linked List Implementation in Go

Hey there DEV.to community! This is a part of my data structures and algorithms series. In this article, we will implement a singly linked list then in the next articles from this series I will implement other kinds of linked lists as well using Go. Image source: GeeksforGeeks To implement a singly linked list we need to structures, a node and a singly linked list itself. But before beginning to code here is how I like to organize my code: project ├── singly_linked_list │ ├── node.go │ └── list.go └── main.go Enter fullscreen mode Exit fullscreen mode A node only…
Read More
How is KALP solving the Blockchain Trilemma?

How is KALP solving the Blockchain Trilemma?

Following the recent trends in Blockchain and decentralised application development, smart contracts have become the backbone of countless digital platforms. As web3 enthusiasts know, smart contracts have traditionally been written in languages like Solidity, which we all know has been closely linked with the Ethereum blockchain. However, with the rise of various blockchain ecosystems, there’s a growing demand for alternative programming languages that offer more flexibility, speed, and scalability. One language gaining attention is Go, also known as Golang, which is widely used in backend systems, cloud infrastructure, and blockchain development. KALP Studio, a leading platform for innovative contract development,…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.