Overview Below are some of the ways of declaring multiple constant together Declaring multiple const together with different value and type The declaration can be typed or untyped. Refer to this article…
Tag: go
Constant array or slice in Go (Golang)
Overview Go only supports four types of constant Numeric ( int, int64, float, float64, complex128 etc) String Character or rune Boolean Go doesn’t support const array or slice. It is because in…
String constant in Go (Golang)
Overview In go string constant is represented in two ways Any value that is enclosed between double quotes Any value enclosed between back quotes To better understand string constant in golang it…
Declaring a constant in Go (Golang)
A constant is anything that doesn’t change its value. In Go const can be either of type string, numeric, boolean, and characters. A constant can be declared using the const keyword. An…
Typed and Untyped constant in Go (Golang)
Typed and Untyped Constants In go constant are treated in a different way than any other language. GO has a very strong type system that doesn’t allow implicit conversion between any of…
Global and Local Constant in Go (Golang)
Overview Like any other variable, a constant will be global within a package if it is declared at the top of a file outside the scope of any function. For example, in…
Constant in inner/outer scope in Go (Golang)
Overview A constant declared within an inner scope having a same name as constant declared in the outer scope will shadow the constant in outer scope. Example Output The above program prints…
Can constant be reassigned after its declaration in Go (Golang)
Overview Constant Variable cannot be reassigned after its declaration as it is constant and its value cannot change. If you try to reassign to a constant variable then it will raise a…
Constant in Go (Golang)
This is the chapter 9 of the golang comprehensive tutorial series. Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series Next Tutorial – For LoopPrevious Tutorial –Functions Now let’s check…
Create panic by calling panic function in Go (Golang)
Overview Go provides a special function to create a panic. Below is the syntax of the function This function can be called explicitly by the programmer to create a panic. It takes…