jweinst1
4/28/2016 - 6:29 AM

appending to a slice in go

appending to a slice in go

package main

import (

	"fmt"

)

func main() {
	strs := make([]string, 3)
	strs[0] = "hello"
	strs[1] = "world"
	strs[2] = "doo u "
	//extends slice via built in append function
	strs = append(strs, "fooo")
	strs = append(strs, "dooo")
	fmt.Println(strs[3])
	fmt.Println(strs[4])
}