<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Rokibul Hasan</title>
    <description>The latest articles on Forem by Rokibul Hasan (@rokibulhasan114).</description>
    <link>https://forem.com/rokibulhasan114</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F996978%2F5f204fbd-2c8c-4eb0-b309-123086f78be2.png</url>
      <title>Forem: Rokibul Hasan</title>
      <link>https://forem.com/rokibulhasan114</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rokibulhasan114"/>
    <language>en</language>
    <item>
      <title>Why Our AWS RDS Cost Suddenly Spiked and How We Saved ~40%</title>
      <dc:creator>Rokibul Hasan</dc:creator>
      <pubDate>Wed, 31 Dec 2025 15:57:24 +0000</pubDate>
      <link>https://forem.com/tirixa/why-our-aws-rds-cost-suddenly-spiked-and-how-we-saved-40-op6</link>
      <guid>https://forem.com/tirixa/why-our-aws-rds-cost-suddenly-spiked-and-how-we-saved-40-op6</guid>
      <description>&lt;p&gt;Our AWS RDS cost jumped unexpectedly over the last 2 days, even though usage and traffic were unchanged.&lt;/p&gt;

&lt;p&gt;What went wrong?&lt;/p&gt;

&lt;p&gt;After a deep dive, we found the root cause:&lt;br&gt;
👉 Our Reserved DB Instance (RI) had expired.&lt;/p&gt;

&lt;p&gt;Once the RI expired, the database automatically fell back to On-Demand pricing, which is significantly more expensive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We immediately purchased a new Reserved DB Instance matching:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;li&gt;Instance class&lt;/li&gt;
&lt;li&gt;Multi-AZ&lt;/li&gt;
&lt;li&gt;Region&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This was a billing-only change:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No downtime&lt;/li&gt;
&lt;li&gt;No restarts&lt;/li&gt;
&lt;li&gt;No configuration changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The result&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;💰 ~30–40% reduction in DB instance cost&lt;/p&gt;

&lt;p&gt;📉 Monthly spend became predictable again&lt;/p&gt;

&lt;p&gt;⚡ Savings applied instantly&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key takeaway&lt;/strong&gt;&lt;br&gt;
RI expirations are silent, but their cost impact is immediate.&lt;/p&gt;

&lt;p&gt;Always monitor:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RI expiration dates&lt;/li&gt;
&lt;li&gt;Cost Explorer anomalies&lt;/li&gt;
&lt;li&gt;Billing alerts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A missed RI renewal can cause instant cost spikes, even for stable workloads.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>aws</category>
      <category>awschallenge</category>
      <category>database</category>
    </item>
    <item>
      <title>🧠 Learning Thanos (No, Not the Purple Villain)</title>
      <dc:creator>Rokibul Hasan</dc:creator>
      <pubDate>Sat, 31 May 2025 09:44:29 +0000</pubDate>
      <link>https://forem.com/rokibulhasan114/learning-thanos-no-not-the-purple-villain-2opd</link>
      <guid>https://forem.com/rokibulhasan114/learning-thanos-no-not-the-purple-villain-2opd</guid>
      <description>&lt;p&gt;Hey everyone! 👋&lt;/p&gt;

&lt;p&gt;This week I spent some time learning about &lt;strong&gt;Thanos&lt;/strong&gt; — not the &lt;strong&gt;Marvel villain&lt;/strong&gt;, but the one that works with &lt;strong&gt;Prometheus&lt;/strong&gt; for monitoring in Kubernetes.&lt;/p&gt;

&lt;p&gt;I’ll be honest — when I first heard about Thanos, I thought “Sounds complicated.”&lt;br&gt;
And you know what? It kind of is… but it’s also super useful once you get the hang of it. &lt;/p&gt;

&lt;p&gt;I didn’t build anything fancy, but I did get a minimal setup working: &lt;strong&gt;Prometheus + Thanos Sidecar + MinIO + a simple Go app&lt;/strong&gt; exporting custom metrics. Along the way, I picked up a few interesting lessons worth sharing.&lt;/p&gt;

&lt;h2&gt;
  
  
  🌐 What Even Is Thanos?
&lt;/h2&gt;

&lt;p&gt;If you’re using Prometheus for monitoring, Thanos helps you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Store metrics for a long time&lt;/strong&gt; (not just a few days).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query metrics across multiple Prometheus instances&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Avoid duplicate data&lt;/strong&gt; if you’re running Prometheus in high availability mode.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically: it makes Prometheus &lt;strong&gt;smarter&lt;/strong&gt;, &lt;strong&gt;stronger&lt;/strong&gt;, and more &lt;strong&gt;scalable&lt;/strong&gt;. Think of it like giving Prometheus a cloud brain.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧪 What I Tried
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F084lxzlri3gx1wr5lvqi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F084lxzlri3gx1wr5lvqi.png" alt=" " width="800" height="473"&gt;&lt;/a&gt;&lt;br&gt;
Here’s what I set up (with a lot of Googling and head-scratching):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Sidecar&lt;/strong&gt;: This sits next to Prometheus and helps upload data to a bucket (like S3).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Store&lt;/strong&gt;: Reads data back from that bucket when you want to query old metrics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Query&lt;/strong&gt;: Lets you run PromQL queries across all your data — even from multiple clusters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compactor&lt;/strong&gt;: Cleans up and organizes your stored metrics data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📌 Why I’d Use Thanos Again
&lt;/h2&gt;

&lt;p&gt;If you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use Prometheus for metrics.&lt;/li&gt;
&lt;li&gt;Need to keep metrics longer than a few days.&lt;/li&gt;
&lt;li&gt;Or want to monitor multiple clusters.
…Thanos is worth checking out. It takes some time to get it running, but the payoff is great once you do.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🚀 Want to Try It Yourself?
&lt;/h2&gt;

&lt;p&gt;If you're curious and want to spin it up yourself, I’ve the whole setup here:&lt;br&gt;
👉 GitHub Repo: &lt;a href="//github.com/RokibulHasan7/thanos-demo"&gt;github.com/RokibulHasan7/thanos-demo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It includes all the manifests to deploy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Prometheus.&lt;/li&gt;
&lt;li&gt;Thanos Sidecar, Compactor, Store, and Query.&lt;/li&gt;
&lt;li&gt;MinIO as the object store.&lt;/li&gt;
&lt;li&gt;The demo Go app exposing metrics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You’ll find step-by-step instructions in the README to try everything locally.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>monitoring</category>
      <category>go</category>
    </item>
    <item>
      <title>2024: Leveling Up My Tech Knowledge</title>
      <dc:creator>Rokibul Hasan</dc:creator>
      <pubDate>Mon, 25 Dec 2023 18:41:30 +0000</pubDate>
      <link>https://forem.com/rokibulhasan114/2024-leveling-up-my-tech-knowledge-1fn2</link>
      <guid>https://forem.com/rokibulhasan114/2024-leveling-up-my-tech-knowledge-1fn2</guid>
      <description>&lt;p&gt;The new year is on the horizon, and with it comes the exciting opportunity to reinvigorate our goals and push ourselves towards new heights. As a developer, I'm all about continuous learning and expanding my skillset to stay ahead of the curve. So, for 2024, I'm setting my sights on three key areas that will take my development game to the next level:&lt;/p&gt;

&lt;h2&gt;
  
  
  Mastering the Art of System Design:
&lt;/h2&gt;

&lt;p&gt;System design is the magical glue that holds complex software architectures together. It's about understanding the big picture, making crucial decisions about scalability, reliability, and performance, and then translating those decisions into concrete technical choices. In 2024, I'm diving headfirst into this essential skill. I'll be devouring books like "Designing Data-Intensive Applications" by Martin Kleppmann and "Distributed Systems for Fun and Profit" by Martin Fowler. Online courses, tutorials, and hands-on practice building toy systems will also be on the menu. By the end of the year, I aim to confidently craft robust and efficient architectures that can handle any challenge.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building Microservices Magic:
&lt;/h2&gt;

&lt;p&gt;Microservices are all the rage, and for good reason. This architectural style breaks down monolithic applications into smaller, independent services that communicate with each other via APIs. The benefits are numerous: increased agility, resilience, and scalability. In 2024, I'm going beyond theory and getting my hands dirty building one or two real-world microservices projects. This will involve choosing the right technologies (think Spring Boot, Docker, and Kubernetes), designing APIs, and implementing communication protocols. The thrill of watching independent services seamlessly work together to achieve a larger goal is something I can't wait to experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  DevOps Deep Dive:
&lt;/h2&gt;

&lt;p&gt;DevOps is the bridge between development and operations, ensuring smooth collaboration and efficient software delivery. In 2024, I'm planning a deep dive into this crucial domain. I'll be mastering tools like Git, CI/CD pipelines, containerization technologies, and infrastructure as code. Understanding how to automate deployments, manage configurations, and monitor applications will be my key focus. By the end of the year, I want to be able to confidently say, "I can deploy and manage software like a pro!"&lt;/p&gt;

&lt;p&gt;These three goals, while ambitious, are also incredibly exciting. They promise to open up new avenues for creativity, problem-solving, and career growth. As I embark on this journey, I'm sure to encounter challenges and roadblocks. But with dedication, perseverance, and a healthy dose of caffeine, I know I can achieve my goals and emerge a stronger, more versatile developer.&lt;/p&gt;

&lt;p&gt;So, here's to 2024, a year of learning, building, and pushing boundaries. Who's with me?&lt;/p&gt;

&lt;p&gt;I encourage you to share your own tech goals for the new year in the comments below. Let's support and inspire each other as we embark on our individual journeys of growth!&lt;/p&gt;

&lt;p&gt;Remember, the key to success is to have a clear vision, a well-defined plan, and the unwavering determination to see it through. Happy coding, and here's to a fantastic 2024!&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>kubernetes</category>
      <category>devops</category>
      <category>career</category>
    </item>
    <item>
      <title>Designing an API in Go: Best Practices and Examples</title>
      <dc:creator>Rokibul Hasan</dc:creator>
      <pubDate>Sun, 15 Jan 2023 05:23:33 +0000</pubDate>
      <link>https://forem.com/rokibulhasan114/designing-an-api-in-go-best-practices-and-examples-1fbh</link>
      <guid>https://forem.com/rokibulhasan114/designing-an-api-in-go-best-practices-and-examples-1fbh</guid>
      <description>&lt;p&gt;Golang, also known as Go, is a programming language developed by Google. It is known for its simplicity, efficiency, and strong support for concurrent programming. When designing an API (Application Programming Interface) in Go, there are several principles to keep in mind to ensure that the API is easy to use and maintain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Principles
&lt;/h2&gt;

&lt;p&gt;One important principle is to make the API easy to read and understand. This can be achieved by keeping the API simple and having clear and consistent naming conventions. For example, instead of using complex and generic names for functions and variables, use clear and specific names that accurately describe their purpose. This will make it easier for developers to understand how the API works and how to use it.&lt;/p&gt;

&lt;p&gt;Another principle is to use Go's built-in concurrency features to make the API efficient and scalable. Go's concurrency model is based on goroutines and channels, which allow for efficient and lightweight concurrent execution of code. By using these features, an API can handle a large number of requests without incurring a significant performance penalty.&lt;/p&gt;

&lt;p&gt;It's also important to make the API easy to test and debug. Go provides a built-in testing framework and a number of third-party testing libraries that make it easy to write and run tests for an API. In addition, Go's error handling mechanism, which allows for returning explicit error values, makes it easy to identify and fix bugs in the API.&lt;/p&gt;

&lt;p&gt;Another important principle is to use Go's built-in interfaces to make the API flexible and easy to extend. Go's interface system allows for decoupling the implementation of an API from its interface, making it easy to swap out different implementations without affecting the rest of the code. By designing the API with interfaces in mind, it becomes easy to add new features or make changes to the API without having to make major modifications to the codebase.&lt;/p&gt;

&lt;p&gt;Lastly, it's important to design the API with good documentation in mind. Go has built-in support for inline documentation, which can be automatically extracted and used to generate documentation for the API. In addition, by providing clear and comprehensive documentation, developers will have an easier time understanding how to use the API and how to troubleshoot any issues they may encounter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example:
&lt;/h2&gt;

&lt;p&gt;Here's an example of an API in Go that implements these principles:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "fmt"
)

type UserService interface {
    GetUser(id int) (*User, error)
    CreateUser(user *User) error
    UpdateUser(user *User) error
    DeleteUser(id int) error
}

type User struct {
    ID int
    Name string
    Email string
}

type userService struct {
    users map[int]*User
}

func (s *userService) GetUser(id int) (*User, error) {
    user, ok := s.users[id]
    if !ok {
        return nil, fmt.Errorf("user with id %d not found", id)
    }
    return user, nil
}

func (s *userService) CreateUser(user *User) error {
    if _, ok := s.users[user.ID]; ok {
        return fmt.Errorf("user with id %d already exists", user.ID)
    }
    s.users[user.ID] = user
    return nil
}

func (s *userService) UpdateUser(user *User) error {
    if _, ok := s.users[user.ID]; !ok {
        return fmt.Errorf("user with id %d not found", user.ID)
    }
    s.users[user.ID] = user
    return nil
}

func (s *userService) DeleteUser(id int) error {
    if _, ok := s.users[id]; !ok {
        return fmt.Errorf("user with id %d not found", id)
    }
    delete(s.users, id)
    return nil
}

func main() {
    // Initialize userService
    service := &amp;amp;userService{
        users: make(map[int]*User),
    }
    // Example usage
    user1 := &amp;amp;User{ID: 1, Name: "John Doe", Email: "johndoe@example.com"}
    err := service.CreateUser(user1)
    if err != nil {
        fmt.Println(err)
    }
    user, err := service.GetUser(1)
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println("Name:", user.Name)
    }
    user1.Name = "Jane Doe"
    err = service.UpdateUser(user1)
    if err != nil {
        fmt.Println(err)
    }
    user, err = service.GetUser(1)
    if err != nil {
        fmt.Println(err)
    } else {
        fmt.Println("Name:", user.Name)
    }
    err = service.DeleteUser(1)
    if err != nil {
        fmt.Println(err)
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation of Code
&lt;/h2&gt;

&lt;p&gt;This code defines a struct userService that implements the UserService interface and a struct User that holds the user's information. The struct userService has a map of users as one of its fields, this is a simple way of storing the data in memory, but in a real-world scenario, you would likely use a database or another more robust storage solution.&lt;br&gt;
The userService struct has methods such as GetUser, CreateUser, UpdateUser, and DeleteUser, which correspond to basic CRUD operations. These methods make use of Go's error handling mechanism by returning explicit error values, making it easy to identify and fix bugs in the API.&lt;br&gt;
In the main function, an instance of userService is created and initialized, and examples of how to use the API are given. The example shows how to create a new user, get a user by ID, update a user and delete a user by ID.&lt;/p&gt;

&lt;p&gt;It is important to note that this is a very simple example and it does not cover all the aspects of a real world API but it serves as a good starting point to understand the basic principles of designing an API in Go.&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>api</category>
      <category>programming</category>
    </item>
    <item>
      <title>Go Pro Tips: Mastering Arrays and Slices for Efficient Data Management</title>
      <dc:creator>Rokibul Hasan</dc:creator>
      <pubDate>Thu, 29 Dec 2022 14:40:49 +0000</pubDate>
      <link>https://forem.com/rokibulhasan114/go-pro-tips-mastering-arrays-and-slices-for-efficient-data-management-5eia</link>
      <guid>https://forem.com/rokibulhasan114/go-pro-tips-mastering-arrays-and-slices-for-efficient-data-management-5eia</guid>
      <description>&lt;p&gt;In the Go programming language, arrays and slices are both used to store collections of data. However, there are some key differences between the two that can impact how you use them in your code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Array
&lt;/h2&gt;

&lt;p&gt;An array is a fixed-size collection of elements of the same type. Once you create an array, you cannot change its size. Here's an example of how you might declare and initialize an array in Go:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwf83n9y43qwr3ur0imyh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwf83n9y43qwr3ur0imyh.png" alt="Array in Golang" width="657" height="175"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Slice
&lt;/h2&gt;

&lt;p&gt;On the other hand, a slice is a dynamically-sized, flexible view into the elements of an array. You can think of a slice as a window that you can move over the elements of an array. You can create a slice using the "make" function, or by using the "array[start:end]" syntax. Here's an example of how you might create a slice in Go:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fca1by92ozqkkb1o8em96.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fca1by92ozqkkb1o8em96.png" alt="Slice in Golang" width="644" height="223"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One thing to keep in mind when working with slices is that they can be created with a capacity that is larger than their length. This means that you can append new elements to the slice without having to create a new underlying array every time the slice grows beyond its current capacity. To create a slice with a specific capacity, you can use the "make" function with a third argument:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdauk4jbak9a0bs8th6yn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdauk4jbak9a0bs8th6yn.png" alt="Slice" width="434" height="43"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This creates a slice with a length of 0 and a capacity of 5. You can then append elements to the slice until it reaches its capacity, at which point a new underlying array will be created and the elements will be copied over.&lt;/p&gt;

&lt;p&gt;You can also use the "append" function to grow a slice by appending one or more elements to the end of it. For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1l40qzp0f3gmrpg3wfbu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1l40qzp0f3gmrpg3wfbu.png" alt="Append" width="519" height="78"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will add the elements 4, 5, 6, and 7 to the end of the slice "d".&lt;/p&gt;

&lt;p&gt;Another useful feature of slices is that you can use the "copy" function to copy the elements of one slice into another. For example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0g2txrsgrizb29i869kr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0g2txrsgrizb29i869kr.png" alt="Copy Function" width="642" height="76"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will copy the elements of slice "e" into slice "d", replacing the existing elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  Differences between Array and Slice
&lt;/h2&gt;

&lt;p&gt;One key difference between arrays and slices is that slices are more flexible and easier to work with in most cases. Because slices are dynamically sized, you can easily append new elements to them or remove elements from them without having to worry about resizing the underlying array. In contrast, if you want to change the size of an array, you must create a new array and copy the elements over.&lt;/p&gt;

&lt;p&gt;Another difference is that slices are reference types, while arrays are value types. This means that when you pass a slice to a function or assign it to a new variable, you are actually passing a reference to the underlying array. In contrast, when you pass an array to a function or assign it to a new variable, a new copy of the array is created.&lt;/p&gt;

&lt;h2&gt;
  
  
  When should you use an array and when should you use a slice?
&lt;/h2&gt;

&lt;p&gt;In general, you should use a slice whenever possible because it is more flexible and easier to work with. However, there are a few situations where you might want to use an array instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;When you need to store a large amount of data and you want to minimize the overhead of creating and managing slices.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you need to pass an array to a function that expects a fixed-size array as an argument.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When you need to create a multidimensional array and you want to use a syntax like "array[i][j]" to access the elements.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here's an example of how you might use an array and a slice in Go to store and process a list of integers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4db809xd3a87hfc50tkd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4db809xd3a87hfc50tkd.png" alt="Array and Slice" width="513" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope this helps give you a better understanding of the differences between arrays and slices in Go, and how to use them effectively in your code. As a general rule, you should use slices whenever possible because of their flexibility and ease of use, but don't hesitate to use arrays when you have specific needs that can't be met with slices.&lt;/p&gt;

</description>
      <category>go</category>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
