xxxxxxxxxx
// declaring an empty array of strings
var days []string
// declaring an array with elements
days := [ ]string{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}
xxxxxxxxxx
days := [ ]string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}
weekdays := days[0:5]
fmt.Println(weekdays)
// This returns: [Monday Tuesday Wednesday Thursday Friday]
xxxxxxxxxx
youtubeSubscribers := map[string]int{
"TutorialEdge": 2240,
"MKBHD": 6580350,
"Fun Fun Function": 171220,
}
fmt.Println(youtubeSubscribers["MKBHD"]) // prints out 6580350
xxxxxxxxxx
// our Person struct
type Person struct {
name string
age int
}
// declaring a new `Person`
var myPerson Person