I have a function returning 2 values: string
and []string
func executeCmd(command, port string, hostname string, config *ssh.ClientConfig) (target string, splitOut []string) {
...
return hostname, strings.Split(stdoutBuf.String(), " ")
}
This function is passed down to a go routine channel ch
ch <- executeCmd(cmd, port, hostname, config)
I understand that when you want assign 2 or more values to a single variable, you need to create a structure
and in case of go routine, use the structure to make
a channel
type results struct {
target string
output []string
}
ch := make(chan results, 10)
Being a beginner in GO, I don't understand what I am doing wrong. I have seen other people having similar issue as mine but unfortunately the answers provided did not make sense to me