Welcome to robles.io!

This is my blog where I’ll publish posts with things I find interesting and/or want to reference in the future. I hope you find it useful.

Golang Factory Method Pattern

Using the Factory Method Creational Design Pattern in Golang

The Factory Method Pattern is a creational design pattern that facilitates the use of a single product interface with different concrete implementations of said product. It does this by handling the creation of said product implementations.

This makes it possible to add additional concrete implementations of the target interface without modying client code, minimizing the amount of code changes needed to introduce or change functionality. This, in turn, minimizes the chances of introducing bugs into the application. If you are unfamiliar with interfaces in golang, see this post before proceeding.

[Read More]

Golang Interfaces

Using Interfaces in Golang

In golang, the interface type is a collection of method signatures. Any type that implements the methods defined in the interface is said to “implement/satisfy that interface”. Put another way, interfaces allow you to define a set of methods that can be implemented by different types in different ways. This functionality allows you to define a single interface method that can use the underlying method from a number of different types and their differing implementations.

[Read More]

Golang Structs

Using Structs in Golang

Golang provides built-in types such as bool, byte, string as well as the ability to define custom types. Users create a custom type by defining a collection of fields known as a struct. Each field has an explicitly defined type; the type can be a built-in type or a user defined type. Because they can be used to store complex information records and accommodate associated method functions, structs are considered the go equivalent of classes used in traditional object oriented programming.

[Read More]

Terraform: Introduction to count

Using count with resources in Terraform

In the course of using Terraform, you will undoubtedly encounter the need to build more than one of something. Be it an instance group, cloud function, or VPC, Terraform has a couple of options for specifying multiple instances of a resource: count and for_each.

This post will discuss the use of count.

[Read More]

Golang Maps

Using Maps in Golang

In golang, the map type is an unordered collection of key-values and is commonly referred to as a hash table, associative array, or dictionary.

Maps have the following properties:

  • Each key can exist only once (no duplicates)
  • Keys are unordered (the order of keys may differ each time you access the map)
  • Key lookups and modifications are fast

Maps are a useful data structure as they allow us to store complex information in a way that can be easily and quickly created, accessed, and modified.

[Read More]