Good afternoon colleagues, I come with the following question I am developing in an Iris framework and I have encountered the following problem, the manipulation of data types my code is this:
//ExpresionRegularMgo estructura de ExpresionRegulars mongo
type ExpresionRegularMgo struct {
ID bson.ObjectId 'bson:"_id,omitempty"'
Id string 'bson:"ID"'
Nombre string 'bson:"Nombre"'
Expresion string 'bson:"Expresion"'
Etiquetas []string 'bson:"Etiquetas"'
Estatus bson.ObjectId 'bson:"Estatus"'
FechaHora time.Time 'bson:"FechaHora"'
}
//ExpresionRegularElastic estructura de ExpresionRegulars para insertar en Elastic
type ExpresionRegularElastic struct {
Id string 'json:"ID"'
Nombre string 'json:"Nombre"'
Expresion string 'json:"Expresion"'
Etiquetas []string 'json:"Etiquetas"'
Estatus bson.ObjectId 'json:"Estatus"'
FechaHora time.Time 'json:"FechaHora"'
}
At the moment of concatenating the strings I have problems in the types [] string, bson.ObjectId and time.Time, I am concatenated in such a way that they are displayed on my page in the following way
func GeneraTemplatesBusqueda(ExpresionRegulars []ExpresionRegularMgo) (string, string) {
floats := accounting.Accounting{Symbol: "", Precision: 2}
cuerpo := ''
cabecera := '<tr>
<th>#</th>
<th>Id</th>
<th>Nombre</th>
<th>Expresion</th>
<th>Etiquetas</th>
<th>Estatus</th>
<th>FechaHora</th>
</tr>'
for k, v := range ExpresionRegulars {
cuerpo += '<tr id = "' + v.ID.Hex() + '" onclick="window.location.href = '/ExpresionRegulars/detalle/' + v.ID.Hex() + '';">'
cuerpo += '<td>' + strconv.Itoa(k+1) + '</td>'
cuerpo += '<td>' + v.Id + '</td>'
cuerpo += '<td>' + v.Nombre + '</td>'
cuerpo += '<td>' + v.Expresion + '</td>'
cuerpo += '<td>' + v.Etiquetas + '</td>'
cuerpo += '<td>' + v.Estatus + '</td>'
cuerpo += '<td>' + v.FechaHora + '</td>'
cuerpo += '</tr>'
}
return cabecera, cuerpo
}
However I have problems regarding the handling of types in v. Labels, V. Statutes and v. Date Time, what could be the way to concatenate those objects in the output to show the html?
Thanks in advance and regards