go

Logging in Golang

Logging in Golang

Practical insights into Golang logging, including how to use the log package, popular third-party libraries, and tips for structured logging. Table of Contents Introduction to Golang Logging The Standard Library: log Package How I Learned to Stop Worrying and Love fmt.Println() Popular Third-Party Logging Libraries Because Reinventing the wheel is so 2000s Structured Logging in Go JSON: Its whats for dinner Configuring Log Levels and Output Formats Choosing your adventure Integrating with Observability Platforms Because logs are lonely without metrics and traces Best Practices and Performance Considerations How to not shoot yourself in the foot Real-World Examples I really have…
Read More
Golang Field ordering matters?

Golang Field ordering matters?

Greetings, Gophers! During the initial year of working with Golang, I kept thinking that there must be ordering of fields and I thought why should I be bothered about it? Well, it is only fields, only something wrong could it be, I right? As most of the other novices, I thought it was not worth bothering with. In other words, how vital could it be that certain fields in a struct, would be put in a specific order? Well, a great deal! Field ordering is one of the aspects ignored at the beginning but as one proceeds with the tutorial…
Read More
Build generative AI applications in Go using Amazon Titan Text Premier model

Build generative AI applications in Go using Amazon Titan Text Premier model

Use Amazon Titan Text Premier model with the langchaingo package In this blog I will walk you through how to use the Amazon Titan Text Premier model in your Go applications with langchaingo which is a Go port of langchain (originally written for Python and JS/TS). Amazon Titan Text Premier is an advanced LLM within the Amazon Titan Text family. It is useful for a wide range of tasks including RAG, agents, chat, chain of thought, open-ended text generation, brainstorming, summarization, code generation, table creation, data formatting, paraphrasing, rewriting, extraction, and Q&A. Titan Text Premier is also optimized for integration…
Read More
Golang Struct Field Scopes

Golang Struct Field Scopes

Struct Field Scopes Exported Fields In other languages, this would be similar to the public access qualifier. If you come from Ruby like me, this would be defining attributes with attr_accessor If the field (i.e. attribute) of the struct starts with an upper case, it would mean that that field is exported, thus accessible outside of the package. Assume we have the following files in Go project: main.go /library /book.go Enter fullscreen mode Exit fullscreen mode We would define book.go in it's own package. // library/book.go // Assume we have a package called "library" which contains a book. package library…
Read More
Unlock the Power of Real-Time UI: A Beginner’s Guide to Streaming Data with React.js, gRPC, Envoy, and Golang

Unlock the Power of Real-Time UI: A Beginner’s Guide to Streaming Data with React.js, gRPC, Envoy, and Golang

Written by Naveen M Background As part of our Kubernetes platform team, we face the constant challenge of providing real-time visibility into user workloads. From monitoring resource usage to tracking Kubernetes cluster activity and application status, there are numerous open-source solutions available for each specific category. However, these tools are often scattered across different platforms, resulting in a fragmented user experience. To address this issue, we have embraced the power of server-side streaming, enabling us to deliver live resource usage, Kubernetes events, and application status as soon as users access our platform portal. Introduction By implementing server-side streaming, we can…
Read More
Defer & Panic Recovery In Go

Defer & Panic Recovery In Go

Panics are caused by operations like accessing elements outside the bounds of an array, null dereference, closing closed channels, and so on. They are abnormal operations that should be avoided by checks in the code, but sometimes these scenarios are missed, and the panic can crash our application. There might be many reasons to recover from a panic, the most obvious being to "fail gracefully" by finishing cleanup operations and properly reporting the errors before exiting. Panic recovery in Go is based on defers, lets take a look at how they work. Each time the function encounters a defer statement,…
Read More
How to Build Your Own Distributed KV Storage System Using the etcd Raft Library (2)

How to Build Your Own Distributed KV Storage System Using the etcd Raft Library (2)

This is the second article in the series "How to Build Your Own Distributed KV Storage System Using the etcd raft Library" - raftexample Log Compaction and Snapshot. Introduction In the first article, we learned and became familiar with the structure of raftexample and the processing flow of a write request. In this article, we will interpret the log compaction and snapshot handling logic in raftexample. Log Compaction and Snapshot The Raft log continuously grows as the cluster operates normally and processes client requests. In practical applications, we need a mechanism to limit the unlimited growth of the log to…
Read More
Go and MongoDB: Building a CRUD API from Scratch

Go and MongoDB: Building a CRUD API from Scratch

Want to create a dynamic web application with a robust backend? Look no further than Go and MongoDB! This powerful combination allows you to build scalable, efficient APIs that handle data creation, reading, updating, and deletion (CRUD) with ease. In this beginner-friendly guide, we'll walk through the process of building a simple CRUD API using Go and MongoDB. We'll cover the essential steps, provide code examples, and sprinkle in useful tips along the way. Getting Started First things first, let's set up our environment: Go Installation: Download and install the latest version of Go from https://go.dev/dl/. MongoDB Setup: If you…
Read More
Implementasi Metode Standard Symmetric Encryption Signature pada Golang

Implementasi Metode Standard Symmetric Encryption Signature pada Golang

Apa Itu Metode Standard Symmetric Encryption Signature? Jadi, gini, metode ini adalah cara untuk mengenkripsi data biar aman dan nggak bisa dibaca sama orang yang nggak punya kunci dekripsinya. Bayangin aja temen-temen punya diary yang temen-temen kunci pake gembok. Hanya orang yang punya kuncinya yang bisa buka dan baca diary temen-temen. Symmetric Encryption Symmetric encryption ini kayak temen-temen dan temennya temen-temen eh ini apa si wkwkwk intinya gitu, punya satu kunci yang sama buat buka gembok. Kunci ini dipake buat enkripsi (mengunci) dan dekripsi (membuka) data. Jadi, baik temen-temen maupun temennya temen-temen bisa mengunci dan membuka data yang sama asalkan…
Read More
Mengenal Asymmetric Encryption: Keamanan Data Tingkat Tinggi dengan Golang

Mengenal Asymmetric Encryption: Keamanan Data Tingkat Tinggi dengan Golang

Apa Itu Asymmetric Encryption? Asymmetric encryption adalah metode enkripsi yang menggunakan dua kunci berbeda: public key (kunci publik) dan private key (kunci privat). Kunci publik digunakan untuk mengenkripsi data, sementara kunci privat digunakan untuk mendekripsi data. Karena karakteristik ini, asymmetric encryption sangat berguna dalam berbagai situasi yang membutuhkan keamanan tinggi dan otentikasi. Berikut beberapa contoh penggunaan dan penjelasan detail kapan menggunakan asymmetric encryption: Mengamankan Transaksi OnlineDalam transaksi online, seperti pembelian di e-commerce atau perbankan online, asymmetric encryption digunakan untuk memastikan bahwa informasi sensitif, seperti nomor kartu kredit atau informasi pribadi, dikirim dengan aman dari pengguna ke server.Prosesnya yaitu pengguna mengenkripsi…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.