I have a data with array of array.
data := [][]int{{1,2,3}, {4,5,6}}
and struct
type A struct { I, J, K int }
Now I want to create instance run time for struct A with each array from data, How do I achieve that? If reflect is a way, then tell how?
This is just an example that I want to show you. But let's say if struct A contains 26 fields from A to Z with type of int and I have 100 slices of data from which I can create/init my struct A, then how it could be possible without using dot notation on struct and just looping over field index and assign that field from slice data?
package main
import (
"fmt"
)
type A struct {
I, J, K int
}
func main() {
data := [][]int{
{1, 2, 3},
{4, 3, 2},
}
var a A
// create instance of type A with params
// initialization for each array in data
fmt.Println(a)
}
Please help me at this link: https://play.golang.org/p/rYuoajn5Ln