Making a wise choice with ec2-instance-selector

AWS has more than 200 instance types under EC2. It’s very tricky to select appropriate ec2-instance types and surely AWS docs can be daunting. You can check the official doc here: https://aws.amazon.com/ec2/instance-types/ ec2-instance-selector is an open-source project by AWS. It is a CLI tool to helps you select compatible instance types. Check out the repo here, https://github.com/aws/amazon-ec2-instance-selector Features You can filter AWS Instance types using criteria like vcpu, memory, network performance, etc. You can use this project as a Go library to embed this functionality into your Golang projects, I will surely embed this in awsctl. Installing ec2-instance-selector On Mac brew tap aws/tap brew install ec2-instance-selector On Linux & Windows, you can download the binary from the release page. verify installation ec2-instance-selector --version v2.4.1 Usage Lookup all the instance type details interactively ec2-instance-selector -o interactive ...

September 2, 2023 · 2 min · Suraj Narwade

Understanding HTTP Server in Go #6 - Mux

Up until now, we’ve been using the DefaultServeMux, but it’s time to wield more control and precision by explicitly using the http.ServeMux. Plus, we’ll look at the powerful frameworks available, like Gorilla Mux and Echo, that take web server functionality to new heights. Check out previous posts: Part 1: https://surajincloud.com/understanding-http-server-in-go-basic Part 2: https://surajincloud.com/understanding-http-server-in-go-using-httpserver-struct Part 3: https://surajincloud.com/understanding-http-server-in-go-handlers Part 4: https://surajincloud.com/understanding-http-server-in-go-multiple-handlers Part 5: https://surajincloud.com/understanding-http-server-in-go-handlefunc Why do we need this? While the DefaultServeMux In Golang does a great job of handling basic routing, there will come a point where you’ll want more control over your application’s routes. This is where the http.ServeMux steps in. It empowers you to explicitly define how your application responds to different routes, giving you fine-grained control over your server’s behaviour. ...

September 1, 2023 · 3 min · Suraj Narwade

Understanding HTTP Server in Go #5 - HandleFunc

Welcome back to the fifth instalment of our in-depth exploration of creating dynamic web servers using Golang! In this post, we’re diving into the fascinating world of HandlerFunc. As you’ve come to expect, GoLang provides us with an elegant and powerful way to handle requests through this mechanism. Let’s embark on this journey of discovery. Check out previous posts: Part 1: https://surajincloud.com/understanding-http-server-in-go-basic Part 2: https://surajincloud.com/understanding-http-server-in-go-using-httpserver-struct Part 3: https://surajincloud.com/understanding-http-server-in-go-handlers Part 4: https://surajincloud.com/understanding-http-server-in-go-multiple-handlers Let’s dive into the code to uncover the magic behind HandleFunc: ...

August 31, 2023 · 2 min · Suraj Narwade

Understanding HTTP Server in Go #4 - multiple handlers

In the previous blog post, we made our webserver useful for the first time where we printed Hello World instead of 404. Check out previous blog posts: Part 1: https://surajincloud.com/understanding-http-server-in-go-basic Part 2: https://surajincloud.com/understanding-http-server-in-go-using-httpserver-struct Part 3: https://surajincloud.com/understanding-http-server-in-go-handlers It was still useless as it was printing the same response on all the paths. Now in real real-world scenario, we won’t have just one URL right, We will need multiple paths and handlers and we still don’t have mux so now in this case we can still have multiple handlers ...

August 31, 2023 · 2 min · Suraj Narwade

Understanding HTTP Server in Go #3 - Handlers

Welcome to the exciting third instalment of our journey into creating web servers using Golang. In our previous articles, we covered the basics of creating a web server and explored the concept of custom servers using the http.Server struct. Check out the previous blog posts: \ Part 1:* https://surajincloud.com/understanding-http-server-in-go-basic \ part 2:* https://surajincloud.com/understanding-http-server-in-go-using-httpserver-struct However, as you might have noticed, our server was, until now, simply returning a 404 error. Fear not, because in this article, we’re about to breathe life into our server by diving into the realm of handlers. ...

August 30, 2023 · 2 min · Suraj Narwade

Understanding HTTP Server in Go #2 - using http.Server struct

Welcome back to the second part of our exploration into building web servers using GoLang! In the previous blog post, we discussed creating a basic web server using the http.ListenAndServe function. However, this does not give us more control over the server config and to gain more control and flexibility over the server’s behaviour, you’re in for a treat. In this article, we’ll delve into the world of custom servers by utilizing the http.Server struct. ...

August 29, 2023 · 2 min · Suraj Narwade

Understanding HTTP Server in Go #1 - Basic

The net/http package in Go offers a powerful set of tools for constructing HTTP servers to handle incoming requests and send responses. In this article, we’ll dive into setting up a basic HTTP server. Before we delve into the specifics, let’s familiarize ourselves with a couple of key terms: Multiplexer (or Mux): This is an essential component of an HTTP server that routes incoming requests to the appropriate handlers based on the requested paths or URLs. we will see this in detail in upcoming posts. With this foundation in mind, let’s explore how the net/http package simplifies the process of creating an HTTP server. ...

August 29, 2023 · 3 min · Suraj Narwade

Types of DNS records

While working with route53, I came across a couple of DNS records which were new to me. There are several types of DNS (Domain Name System) records, each with a specific purpose. Here are some of the most common types: A record (Address record) Maps a hostname to an IPv4 address. example.com IN A 192.0.2.1 AAAA record (IPv6 Address record) Maps a hostname to an IPv6 address. example.com IN AAAA 2001:db8::1 CNAME record (Canonical Name record) Maps an alias hostname to the true hostname (canonical name). ...

August 23, 2023 · 2 min · Suraj Narwade

fmt in Golang - formatting I/O

fmt is one of the essential packages in Golang. fmt stands for “format.” This package allows us to format strings, print output, and interact with the standard input/output streams. In this blog post, we will explore the key functionalities of the fmt package. you can import the package as shown: import "fmt" Printing to standard output There are various functions available for printing such as fmt.Println , fmt.Print and fmt.Print Println This will print a line with a new line at the end ...

July 30, 2023 · 3 min · Suraj Narwade

Using Go modules with a Private GitHub repository

working with open-source Go modules is more straightforward, you add them in Go mod files and run Go mod commands and it just works. Recently, I came across private Go modules usage in one of my projects at work and thought of writing about it so it can help someone :) if you have only one repo then you can do export GOPRIVATE=github.com/yourorg/yourrepo If you have more than one private module, you can run the following: ...

July 28, 2023 · 1 min · Suraj Narwade