Splitting strings in golang
Split command in the strings package can help us !
str := "Test message !" splittedStr := strings.Split(str, " ") fmt.Println(len(splittedStr)) fmt.Println(splittedStr[0])
result :
3
TestAlso we can use strings.Fields command for parsing by space
fields := strings.Fields("Test Value!")
fmt.Println(len(fields))
fmt.Println(fields[0])result :
2
Test