Declaring an Integer or String Array of Five Elements in Go
Declaring an Array
To declare an array, you use the following syntax
Syntax
var array_name [size_of_array]data_type
<pre class="language-jsx"><code class=" language-jsx">package main
import (
"fmt"
"reflect"
)
func main() {
var intArray [5]int
var strArray [5]string
fmt.Println(reflect.ValueOf(intArray).Kind())
fmt.Println(reflect.ValueOf(strArray).Kind())
}</code></pre>
<pre class="language-jsx"><code class=" language-jsx">array
array</code></pre>
Most Helpful This Week
Most Helpful This Week
Various examples of Carbon date-time package in GolangHow to check pointer or interface is nil?Example: Stack and Caller from RUNTIME packageSample program to create csv and write dataDifferent ways to convert Byte Array into StringExample of Sscan vs Sscanf vs Sscanln from FMT PackageVarious examples of printing and formatting in GolangGolang Read Write and Process data in CSVHow to rotate an image?Example of Fscan, Fscanf, and Fscanln from FMT Package