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
How to Decode or Unmarshal bi-dimensional array of integers?How to print string with double quote in Go?Simple example of Map initialization in GoHow to set, get, and list environment variables?Example of Switch Case with Break in For LoopHow to find length of Map in Go?Different ways for Integer to String ConversionsHow to trim leading and trailing white spaces of a string in Golang?What is GOPATH?How to convert Colorful PNG image to Gray-scale?