List (Array or Slice)
package main
import (
"fmt"
"strings"
)
func main() {
sentence := "I love you guys!"
words := strings.Split(sentence, " ")
fmt.Printf("%#v\n", words)
for index, word := range words {
fmt.Printf("%d. %s\n", index, word)
}
for _, word := range words {
fmt.Printf("%s ", word)
}
new_words := [...]string{"Do", "you", "love", "me?"}
for _, word := range new_words[:] {
fmt.Printf("%s ", word)
}
}Last updated
Was this helpful?