How to iterate over words of String in Go Language?
Hello everyone, in this tutorial we will show you how to iterate over all the words of String in the Go Programming language. How to iterate over all the words of the string in Go Language? Using for-range loop package main import ( "fmt" "strings" ) func main() { teststr := "This is a sample sentence." str := strings.Fields(teststr) for _, word := range str { fmt.Println(word) } } Output: This is a sample sentence. More Go language topics, How to make a delay in Go Language How to iterate over all the characters of the string in Go Language Trim a string in Go Language Check if a String is an Integer in Go Language Sort a String Array/Slice in Go Language Program to check if a string contains the substring How to Split a String by Space in Go Language? Trigonometry with Go - Sin, Cos, Tan Functions Examples How to iterate over a map in Go? Go Arrays - Program to Find Largest & Smallest Element Go Arrays - Program t