Posts for golang

Deven
Deven wrote

Learn How to use strings in Golang

In this article, you are going to learn about how to use strings in the Go language. In Go language, strings are immutable which means it is a read-only slice of bytes. Once you have declared a string you will not be able to change it in the Go language. This makes strings different from […]

December 14, 2021 in Code examples & GoLang
Deven
Deven wrote

Learn How to iterate over a map in Golang

In this article, you are going to learn about how to iterate over a map in the Go language. Golang provides a built-in associative data type named Map which is basically a collection of key-value pairs. On the map, you can retrieve, delete or update values with the help of keys. It is also known […]

December 14, 2021 in Code examples & GoLang
Deven
Deven wrote

Learn How to use goto statement in Golang

In this article, you will learn about how to use goto statement in Golang. Goto statement is found in many programming languages. It is altered the normal sequence of program execution by transferring control to some other part of the program. The goto statement is also known as the unconditional jump statement. In the Go […]

December 10, 2021 in Code examples & GoLang
Deven
Deven wrote

Learn how to use copy function in Golang

In this article, you are going to learn about how to use copy function in the Go language. In Go language, you can copy one slice into another slice. To do so, you need to use the copy() function. This function is provided by Go-builtin packages. It simply takes two slices that is dst and […]

December 10, 2021 in Code examples & GoLang
Deven
Deven wrote

Learn about Ternary operator in Golang

In this article, you will learn about the ternary operator in the Go language. A ternary operator is a kind of operator that takes three operands and helps programmers to make decisions. It is a shorter form of if else conditional statement. As it takes three operators, it is called the ternary operator. An example […]

December 9, 2021 in Code examples & GoLang
Deven
Deven wrote

Learn How to reverse a string in Golang

In this article, you will learn about how to reverse a string in the Go language. Reverse a string means printing a given string from the backward. Like, the first letter of a given string to the last and last one into the first and so on. You can perform this action in Go language […]

December 9, 2021 in Code examples & GoLang
Deven
Deven wrote

How to concatenate strings in golang?

In this article, you are going to learn about string concatenation in Golang. String concatenation means the way of adding two or more strings into a new single string. Like other programming languages, Golang has the functionality of string concatenation. In Go language, the string is a read-only slice of bytes that is also known […]

December 9, 2021 in Code examples & GoLang
Deven
Deven wrote

How to read file line by line in Golang

In this article, you are going to learn about how to read file line by line in Golang. Golang is an open-source programming language which is developed by Google. By using Golang you can do so many things, reading files line by line is one of them. To read a file in Golang, we will […]

December 9, 2021 in Code examples & GoLang
Deven
Deven wrote

How to check if file exists in Golang

In this article, you will learn about how to check if a file exists or not in Golang. In Golang, you can check for the existence of a file by using Stat() function. It is provided by os package in Golang. Basically, the Stat() function returns a FileInfo with the named file and it will […]

December 9, 2021 in Code examples & GoLang
Deven
Deven wrote

How to convert float to int in Golang

In this article, you are going to learn about how to convert a float64 number into an integer in Golang. In Golang, datatypes are very strict which means if you declare a variable type as float64 you can not write any other value except float number. If you try to write an integer number into […]

December 9, 2021 in Code examples & GoLang
Deven
Deven wrote

How to setup GoLang Authentication with JWT token

Golang Authentication is the process of recognizing the user’s identity. That means based on users’ credentials, one will be able to perform certain types of action. For example, you have a blog application where anonymous users can visit and see the blogs, but the moment the user wants to do activities like, comment, or create […]

December 3, 2021 in GoLang & Tutorials
Deven
Deven wrote

How to check typeOf a variable in Golang

In this article, you are going to learn about how to check typeof variable in Golang. Like other programming languages, Golang has different types of variables. such as integer, string, and so on. To check a variable type, GoLang provides a reflection package. With the help of this package, you can easily detect a variable […]

December 3, 2021 in Code examples
Deven
Deven wrote

Golang if else statement examples

In Golang the common use of the if else statement is consistent with other C-style languages, except for the lack of parentheses around the clause and while the braces are required: Consider the following example: Golang permits an initialization statement to continue the condition clause in an if statement. consider the following example: In the code snippet above cat variable is only scoped to if statement. but we can […]

February 8, 2021 in Code examples
Deven
Deven wrote

Golang convert int to string example

In Golang, you can convert int to string  using the following functions. strconv.FormatInt strconv.Itoa 1. Golang convert int to string using strconv.Itoa we converted the convert variable into a string using Itoa method. the above code ouputs 9278 2. Golang convert int to string using strconv.FormatInt we converted the convert2 variable into a string using FormatInt […]

February 7, 2021 in Code examples