Engineering Blog

                            

Cloud Native

Project misorganization

Project organization is one of the most common mistake made by Go Developer. Go provides a lots of freedom for designing the packages and modules hence it is not easy task to organize the project. is The purpose of organizing the project are maintainability, readability, consistency and so on.

Any says nothing

The interface type that specifies zero methods is known as the empty interface: interface{} An empty interface may hold values of any type. (Every type implements at least zero methods.) Empty interfaces are used by code that handles values of unknown type. With Go 1.18 the predeclared type any became an alias for an empty…

Creating confusion with octal literals

Octal is a number system with base 8, it has 8 values (0, 1, 2, 3, 4, 5, 6, and, 7). In Go programming language, an octal literal can be written with the prefix 0 (Zero). The value which is prefixed with 0 is considered as an octal value and it can be used in the program statements like…

Neglecting integer overflow

Concepts Integer is a basic data types. Golang supports integer data types extensively. Integer are divided into two types which are signed and unsigned integer. Now we will see it’s types Signed integer in go Types Range Types Range int8 -128 to 127 int16 -32768 to 32767 int32 -2147483648 to 2147483647 int64 -9223372036854775808 to 9223372036854775807 Types…

Not understanding slices length and capacity

Slice is a variable-length sequence which stores elements of a similar type, you are not allowed to store different type of elements in the same slice. It is just like an array having an index value and length, but the size of a slice is resized they are not in fixed-sized just like an array….

Ignoring the fact that elements are copied in range loops

Range is the form of for loop that iterates over a slice or map. We may forget or be unaware of how a range loop assigns values, leading to common mistakes. First, let’s remind ourselves how to use a range loop; then we’ll look at how values are assigned. Concepts A range loop allows iterating…

Using a filename as a function input

While creating a new function that reads the file, passing the filename as an argument is not considered best practice and might have negative effects such as making it difficult to write test cases for a variety of criteria. Suppose we want to implement a function to count the number of empty lines in a…

Ignoring how defer arguments are evaluated

In order to understand how arguments are processed using the defer keyword, let’s consider a specific example. Suppose we have a function that needs to execute two other functions, called foo and bar. Additionally, this function needs to handle some status information related to its execution. We can use the defer keyword to ensure that…

Misunderstanding variable scope in JavaScript

Misunderstanding variable scope in JavaScript

In this post, we are going to understand variable scope and difference between var, let and const keywords in javascript. Variable scope is tricky concept for new developers., especially in javascript. Most of beginner developers make common mistake like defining the variable inside the function and expecting it to access outside the function. Understanding var,…

Using index as a key in React (anti-pattern)

What are lists in React ? Lists are used to display data which are similar in ordered format . Often they have same type i.e an array of similar kind of data rendered into a list tag using some version of for loop. How does react render lists? DOM Before we learn how react renders lists…