I have two arguments name and value, that I am trying to parse at runtime.
At run time I am passing the following values:
name = text,text,text,text,text
value = 0 ,285,404,6,24
Currently the output is as following;
Parameters: {"text,text,text,text,text":"0,285,404,6,24"}
when actually it must display as,
Parameters: {"text":"0"}
Parameters: {"text":"285"}
Parameters: {"text":"404"}
Parameters: {"text":"6"}
Parameters: {"text":"24"}
Following is my code;
package main
import "fmt"
func main() {
var m string
var matchField = []string{"index,index,index,index"}
var matchValue =[]string{"29,4,87,54"}
for i := 0 ; i < 1 ; i++ {
m = parameter(matchField[i], matchValue[i])
fmt.Printf("Result: %s
", m)
}
}
func parameter(name string, value string) (matcher string) {
var result string
if name != "" || value != "" {
result = fmt.Sprintf("{\"%s\":\"%s\"}", name, value)
}
return result
}
I wanted to know how to display the output accurately.