os.Stat and os.IsNotExist() can be used to check whether a particular file or directory exist or not. File Exists Folder Exists
Tag: golang
Double, Single and Back quotes in Go (Golang)
Double quotes It is used to define a string. A string defined within double quotes will honor escaping characters. For, eg for when printing a string having \n there will be a…
Character in Go (Golang)
Overview Golang does not have any data type of ‘char‘. Therefore byte is used to represent the ASCII character. byte is an alias for uint8, hence is of 8 bits or 1…
Default Zero Value of all Types in Go (Golang) With Examples
Default Value Table Type Default Value Integer 0 Float 0 Complex Number 0 Real and 0 Imaginary Part Byte 0 Rune 0 String “” Bool false Array Every array value to its…
Hex and Octal in Golang
Overview Hex numbers are base 16 Octal numbers are base 8 Hex Numbers Hex numbers can be written using prefix 0x or 0X in GO. When Go sees any number starting with…
Know Size and Range of int or uint in Go (Golang)
Overview int is a signed Integer data type uint is an unsigned Integer data type Size and range of int and uint in go is platform-dependent meaning that the size and range…
Bubble Sort in Go (Golang)
Introduction In bubble sort: In each iteration i (starting with 0) , we start from first element and repeatedly swap adjacent elements if in wrong order up till length (len-i) where len…
Find the type of an object in Go (Golang)
This article will describe different ways of knowing the type of an object in Go Using Reflect Package Reflect package provides some useful inspect functions that let us know the type Output:…
Function/Method Overloading in Golang (Alternatives/Workaround)
Function/Method Overloading means that that the same function/method name can be used with a different number and types of parameters See this post for difference between function and method in Go –…
Difference between method and function in GO
There are some important differences between method and function. Let’s see the signature of both Function: Method: From the above signature, it is clear that method has a receiver argument. A receiver…