I am a novice in Go programming language. I am writing a code to input from cli for client and pass the values to server for processing. both client and server are residing locally.
code :
package main
import (
"flag"
"fmt"
"strings"
)
func main() {
text := gettext()
fmt.Println(text)
result := strings.Split(text, " ")
for i := range result {
fmt.Println(result[i])
}
}
func gettext() []string {
flag.Parse()
text := flag.Args()
if len(text) < 1 {
fmt.Println("Please enter radius")
}
return text
}
when i run from command line its is giving me following error :cannot use text (type []string) as type string in argument to strings.Split
Basically i want to separately print values from []string .
Can you please let me know how to do it. I tried using strings.split.
Thanks.