Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion hello/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,28 @@ package main

import (
"fmt"
"sort"
)

func main() {
fmt.Println("Hello from Go!")
var colors = []string{"Green", "red", "blue"} // now [] it's a slice , i can add new items
fmt.Println(colors)
colors = append(colors, "Purple")
fmt.Println(colors)
colors = append(colors[:len(colors)-1])
fmt.Print(colors, "\n")

numbers := make([]int, 5) //([]int, 5(number of items) , 5 (capacity that caps the number of items))
numbers[0] = 134
numbers[1] = 72
numbers[2] = 32
numbers[3] = 12
numbers[4] = 156
fmt.Println(numbers)
numbers = append(numbers, 235)
fmt.Println(numbers)
// sort slice by adding the sort package
sort.Ints(numbers)
fmt.Println(numbers)

}