go - Variable defined in Golang -


this question has answer here:

i create var of type

var respdata   []responsedata  type responsedata struct {    datatype       string          component      string          parametername  string          parametervalue string          tablevalue     *[]rows  }  type tabrow struct {    colname     string     colvalue    string     coldatatype string  }  type rows *[]tabrow 

i want fill tablevalue of type *[]rows. can please tell me example assigning values in tablevalue.

slices reference type (it kind of pointer), don't need pointer slice (*[]rows).

you can use slice of slices though tablevalue []rows, rows being slice of pointers tabrow: rows []*tabrow.

tr11 := &tabrow{colname: "cname11", colvalue: "cv11", coldatatype: "cd11"} tr12 := &tabrow{colname: "cname12", colvalue: "cv12", coldatatype: "cd12"} row1 := rows{tr11, tr12} rd := &responsedata{tablevalue: []rows{row1}} fmt.printf("%+v", rd ) 

see this example.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -