This is a creation in Article, where the information may have evolved or changed.
I've been looking for a lot of result set encapsulation is not very good, so I encapsulated the next.
Strfirsttoupper the first letter of a string into uppercase
/** * Package result set * /funcRowresult (Rows *sql. Rows) []Interface{} {//Dictionary type //Constructs Scanargs, values two arrays, each value of Scanargs points to the address of values correspondingColumns, _: = Rows. Columns () Values: = Make([]sql. Rawbytes,Len(columns)) Scanargs: = Make([]Interface{},Len(values)) forI: =RangeValues {Scanargs[i] = &values[i]}varReturnarrs []Interface{} forRows. Next () {err: = rows. Scan (Scanargs ...)ifErr! =Nil{Panic(Err. Error ())}varValuestringRelativjson: = Newbeemap () forI, col: =RangeValues {ifCol = =Nil{value =""}Else{value =string(COL)}ifRelativjson.set (Strfirsttoupper (Columns[i]), value) {Continue}} Returnarrs =Append(Returnarrs, RELATIVJSON.BM)}returnReturnarrs}