Skip to content

Instantly share code, notes, and snippets.

@hi-manshu
Created July 12, 2018 15:20
Show Gist options
  • Save hi-manshu/568658b968df9cd9430d1c6bfbd759f9 to your computer and use it in GitHub Desktop.
Save hi-manshu/568658b968df9cd9430d1c6bfbd759f9 to your computer and use it in GitHub Desktop.
package main
//imported the package fmt
import "fmt"
func main() {
// we have declared an array with name "nameArray" of size 2 and data-type integer
var nameArray [2]string
//we assigned value Himanshu to the first element in the array nameArray
nameArray[0] = "Himanshu"
//we assigned value Himanshu to the second element in the array nameArray
nameArray[1] = "Singh"
//Printing the elements in the array by accessing it by the position
fmt.Println("First Name:", nameArray[0])
fmt.Println("Second Name:", nameArray[1])
}
>>go run arrayExample.go
>>First Name: Himanshu
>>Second Name: Singh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment